[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[TRNSYS-users] Sharing some information - (simple example and some hints to change a variable from input to parameter and vice versa)



Hello everybody

 

I was trying to change a variable from parameter category to input category. At the beginning I had problem to perform it. Here is an example which illustrates the process. If you desire to conduct such a change I hope this example would be helpful.

 

 

Changing a parameter to input or vice versa

At the first glance changing a parameter to an input or vice versa seems to be very simple. In component’s performa, changing the role culminates in the desire change. But unfortunately this change has been made only on performa and we still need to change the related dll and fortran file.

 

Hence here an example for this change would be illustrated as a reference for users desired to perform such a change.

 

Suppose that in type 31 (pipe & duct), we need to change the pipe inside diameter to an input (pipe inside diameter is originally defined as a parameter in type 31).

 

To avoid spoiling the original type31 its better if we generate another component to implement out desire change. Let say we want to implement this change in new component called type 215.

 

Original fortran file of this component is located in: C:\Trnsys17\SourceCode\Types\Type31

 

1-     Copy and past the original fortran file to wherever you want and change the name from type 31 to type 215.

 

2-     Open the new file (we can even use notepad) and change the following items.

 

·    Changing the subroutine name

 

    SUBROUTINE TYPE31(TIME,XIN,OUT,T,DTDT,PAR,INFO,ICNTRL,*)

 


     

      SUBROUTINE TYPE215(TIME,XIN,OUT,T,DTDT,PAR,INFO,ICNTRL,*)

 

·    Changing the type in the script

 

!DEC$ATTRIBUTES DLLEXPORT :: TYPE31

 

 


!DEC$ATTRIBUTES DLLEXPORT :: TYPE215

 

 

·    Changing the add one to numbers of input and deduct one from numbers of parameters

 

     PARAMETER (NP=6, NI=3, NOUT=7, ND=0)

 

 

     PARAMETER (NP=5, NI=4, NOUT=7, ND=0)         

 

·    Define the variable type of the new input variable ( Pipe inside diameter)

It is worth mentioning that ‘LE1’ represent Meter as type of pipe inside diameter

 

      DATA YCHECK /'TE1','MF1','TE1'/

 

 

      DATA YCHECK /'TE1','MF1','TE1',’LE1’/

 

 

·    Delete the “Pipe inside diameter” from parameter category and resort the order of the rest

 

 

D=PAR(1)

           IF(D.LE.0.) CALL TYPECK(-4,INFO,0,1,0)

 

 L=PAR(2)

           IF(L.LE.0.) CALL TYPECK(-4,INFO,0,2,0)

 

U=PAR(3)

           IF(U.LT.0.) CALL TYPECK(-4,INFO,0,3,0)

 

RHO=PAR(4)

           IF(RHO.LE.0.) CALL TYPECK(-4,INFO,0,4,0)

 

CP=PAR(5)

           IF(CP.LE.0.) CALL TYPECK(-4,INFO,0,5,0)

 

T_INIT=PAR(6)

 

 

 


D=PAR(1)

           IF(D.LE.0.) CALL TYPECK(-4,INFO,0,1,0)

 

 L=PAR(1)

           IF(L.LE.0.) CALL TYPECK(-4,INFO,0,2,0)

 

U=PAR(2)

           IF(U.LT.0.) CALL TYPECK(-4,INFO,0,3,0)

 

RHO=PAR(3)

           IF(RHO.LE.0.) CALL TYPECK(-4,INFO,0,4,0)

 

CP=PAR(4)

           IF(CP.LE.0.) CALL TYPECK(-4,INFO,0,5,0)

 

T_INIT=PAR(5)

 

·    In iteration call reset the parameters again

 

   D=PAR(1)

         L=PAR(2)

         U=PAR(3)

         RHO=PAR(4)

         CP=PAR(5)

         T_INIT=PAR(6)

 

 


   D=PAR(1)

         L=PAR(1)

         U=PAR(2)

         RHO=PAR(3)

         CP=PAR(4)

         T_INIT=PAR(5)

 

 

 

·    Retrieve the current value of the new input

 

TI=XIN(1)

      FLOW=XIN(2)

      TENV=XIN(3)

 

 

 


TI=XIN(1)

      FLOW=XIN(2)

      TENV=XIN(3)

      D= XIN(4)

 

3-     Open the perfoma pertinent to type 31 and after changing the type save it as type 215  on C:\Trnsys17\Studio\Proformas\new components\type 215

 

4-     Change the pipe inside diameter in the new performa from parameter category to input category and save it.

 

5-     6-export the mentioned modified performa for type 215 to fortran.

6-     7- When the CVF6.6B comes up replace the fortran file (modified as above mentioned bullet points) instead of existing and make dll.

7-     Now the new component is ready to use.

 

Thanks to Jeff W. Thornton as the author of type 31 and also David Bradley and Jaime Gonzalez Rodriguez for their replies.

 

Regards

Mehdi Shahrestani