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

Re: [TRNSYS-users] problems creating a new type



Marijke,

1/I want to call the Psychrometrics - subroutine that is already available in Trnsys from my dll.
I found some info on how to do this in the Manuel's Programmer's guide but it is still unclear to
me where in the Fortran-file i have to put these lines. I have the temperature and relative humidity
of the air as inputs but i want to calculate the wet bulb temperature and use it in my calculations
within the dll. How should i do this?

there should be no difference in the way that your Type (in an external DLL) calls the psychrometrics() routine and the way that a standard Type (in TRNDll.dll) calls the psychrometrics() routine. The two basic arguments required by psychrometrics() are a mode switch to tell the routine what property data you are providing and then an array that contains that data and some space for psychrometrics to fill in the rest. The double precision array is usually called PSYDAT() and is dimensioned to 7 spots. One of the clearest examples of callng psychrometrics is in Type33:

C       SET UP ARRAY PSYDAT TO GIVE INFO TO SUBROUTINE PSYCH
100      PSYDAT(1) = PATM
                PSYDAT(2) = TDRY
                PSYDAT(3) = TWET
                PSYDAT(4) = RELHUM
                PSYDAT(5) = TDEW
                PSYDAT(6) = HUMRAT
                PSYDAT(7) = ENTHAL
 
C       DO NOT PRINT ERROR WARNINGS ON THE FIRST CALL
                CALL PSYCHROMETRICS(TIME,INFO,1,MODE,WBMODE,PSYDAT,0,STATUS,*101)
                CALL LINKCK('TYPE 33','PSYCHROMETRICS',1,99)
101      CONTINUE

C       GET INFO FROM PSYCH
                PATM = PSYDAT(1)
                TDRY = PSYDAT(2)
                TWET = PSYDAT(3)
                RELHUM = PSYDAT(4)
                TDEW = PSYDAT(5)
                HUMRAT = PSYDAT(6)
                ENTHAL = PSYDAT(7)
                RHOWM = PSYDAT(8)
                RHOWA = PSYDAT(9)

2/My second question is that i need to call an external file from the dll to choose in that file appropriate
values according to an input value calculated within the dll (like chosing a value from a table). I think
calling a dynamic data can be a good way to do this. Does anyone know how this works and where i
have to put the necessary lines in my fortran-file?

a call to DynamicData is useful if you need the information in your external file to be interpolated. If that is the case, then there should be some information in the 08 Programmer's Guide manual on how to call DynamicData. There are also some good examples again in the code; like with the psychrometrics() call, there is no difference between a call to DynamicData() in the TRNDll.dll and in an external DLL. You might look at Type71 for an example:

C    USE THE DATA SUBROUTINE TO INTERPOLATE TO FIND THE IAM FOR BEAM RADIATION
        X(1)=THETAL
        NXJ(1)=NXDATAL
        X(2)=THETAT
        NXJ(2)=NXDATAT
        CALL DYNAMICDATA(LUDATA1,2,NXJ,1,X,Y,INFO,*821)
        CALL LINKCK('TYPE71','DYNAMICDATA  ',1,99)
821     XKATB=Y(1)

One warning I might give is that when you are dealing with data files that are read by external DLLs, you have to make sure that both the TRNDll.dll and the external DLL are set to the same configuration (release or debug). If the configurations do not match then you will get all sorts of strange errors that will make you crazy.
Cheers,
 David



****************************************************************************************
Thermal Energy System Specialists (TESS), LLC
David BRADLEY                           2916 Marketplace Drive - Suite 104
Partner                                        Madison, WI 53719
Phone: (608) 274-2577 USA
Fax: (608) 278-1475
E-mail: bradley@tess-inc.com
Web Pages:  http://www.tess-inc.com     and      http://www.trnsys.com

"Providing software solutions for today's energy engineering projects"
****************************************************************************************