[TRNSYS-users] Storage variables problem

vincenzo gentile v.gentile89 at gmail.com
Thu Oct 18 08:10:05 PDT 2012


Hello TRNSYS users,
I've written a project for TRNSYS 16.1 in which I use many storage
variables, precisly 36. The project works well, but now I've this
prboblem:
I wont to add more equations and also more storage variables to the
project for many reasons, but if I do one of these operations, or
both, TRNSYS sends me an error message in which says that there is an
inconsistency between the number that I've declared in the
setstoragevariable() and the getstoragevariable() function. But I've
checked many times it and the numbers declared are exactly the same.
The strange thing is that if I don't add or remove the storage
variables, but simply I add equations, TRNSYS gives me the same error
message.

Thanks you in advance for any advice.
Vincenzo Gentile

P.S.
The scheme of the project is this:

...
--------
C    TRNSYS DECLARATIONS
......
DOUBLE PRECISION DTDT,StorageArray(1),PSYDAT(1)		!AN ARRAY CONTAINING
THE DERIVATIVES TO BE PASSED TO THE DIFF.EQ. SOLVER
INTEGER	StorageSize
......
-------
C    PERFORM ANY 'AFTER-ITERATION' MANIPULATIONS THAT ARE REQUIRED HERE
C    e.g. save variables to storage array for the next timestep
      IF (INFO(13).GT.0) THEN
	   CALL getStorageVars(Stored,StorageSize,INFO)
	Stored(1)=Stored(2)
.....
Stored(35)=Stored(36)
CALL setStorageVars(Stored,StorageSize,INFO)
	   RETURN 1
	ENDIF
-------
C    DO ALL THE VERY FIRST CALL OF THE SIMULATION MANIPULATIONS HERE
      IF (INFO(7).EQ.-1) THEN
......
C       SET THE NUMBER OF STORAGE SPOTS NEEDED FOR THIS COMPONENT
          StorageSize=36
	CALL setStorageSize(StorageSize,INFO)

      ENDIF
------
C    DO ALL OF THE INITIAL TIMESTEP MANIPULATIONS HERE - THERE ARE NO
ITERATIONS AT THE INTIAL TIME
      IF (TIME .LT. (getSimulationStartTime() +
     . getSimulationTimeStep()/2.D0)) THEN
C       PERFORM ANY REQUIRED CALCULATIONS TO SET THE INITIAL VALUES OF
THE OUTPUTS HERE
	Stored(1)=PAR(7)
.....
	Stored(36)=wst_9
	
		StorageSize=36
	  CALL setStorageVars(STORED,StorageSize,INFO)
.....
 RETURN 1

      ENDIF
-------
C		ADD YOUR COMPONENT EQUATIONS HERE; BASICALLY THE EQUATIONS THAT WILL
C		CALCULATE THE OUTPUTS BASED ON THE PARAMETERS AND THE INPUTS.	REFER TO
C		CHAPTER 3 OF THE TRNSYS VOLUME 1 MANUAL FOR DETAILED INFORMATION ON
C		WRITING TRNSYS COMPONENTS.

		CALL getStorageVars(STORED,StorageSize,INFO)
	t_letto_in_1=Stored(1)
.....
        w_letto_in_9=Stored(35)
CALL setStorageVars(STORED,StorageSize,INFO)
C	EQUATIONS
.....
-------
C    SET THE STORAGE ARRAY AT THE END OF THIS ITERATION IF NECESSARY

2000  Stored(2)=t_letto_1
         .....
         Stored(36)=wst_9

	CALL setStorageVars(STORED,StorageSize,INFO)
-------
C    SET THE OUTPUTS FROM THIS MODEL IN SEQUENTIAL ORDER AND GET OUT

C		 w_eq
			OUT(1)=wst_2
                        .....
RETURN 1
      END



More information about the TRNSYS-users mailing list