[TRNSYS-users] DTDT and T arrays in C++

keilholz, werner werner.keilholz at cstb.fr
Wed Mar 12 11:14:37 PDT 2008


Dear Knut, 

I think this only means that the person who made the C++ template thought that nobody would ever want to use that feature in C++...

Your C / C++ types will be called like any other TRNSYS type, so if you want to use dtdt, you just have to update the signature in your .h file from 
double to double[] and index it starting from 0 in your code.

(Seen from the call stack, "double &dtdt" and "double []" are compatible, so the signature proposed by Simulation Studio is OK as long as you don't use dtdt). 

The same is true for the &t parameter.

HTH, 

Werner

-----Message d'origine-----
De : knut.erik.enerstvedt at niva.no [mailto:knut.erik.enerstvedt at niva.no] 
Envoyé : mercredi 12 mars 2008 14:41
À : trnsys-users at engr.wisc.edu
Objet : [TRNSYS-users] DTDT and T arrays in C++

Dear TRNSYS users,

I am creating a new Type using C++ where I need to solve several
differential equations numerically. For this I plan to use the DTDT and T
arrays managed by the TRNSYS solver. I would like to write dtdt[n] =
F(t[n]) for equation n,  where F is a non-linear function and t[n] is
automatically retrieved from the previous TRNSYS iteration. This should be
possible in FORTRAN. In C++, however, dtdt and t are declared as double&,
which means that I can store only one differential and corresponding
integration result at a time. Does this mean that in order to solve more
than one equation, I will have to integrate them one at a time, copy the
result from t into another variable, save the results manually (by using
setStorageVars) and retrieve them in the next iteration using
getStorageVars? This is of course a posibility, but I would like to know if
anyone has a better solution to the problem.

Kind regards,
Knut Erik



----------------------------------------------------------------------------------------------------------------------
NIVAs hovedkontor har flyttet til nye lokaler i CIENS - Forskningssenter
for miljø og samfunn; Gaustadalléen 21, 0349 Oslo. Meld deg på vårt
nyhetsbrev på www.niva.no


_______________________________________________
TRNSYS-users mailing list
TRNSYS-users at engr.wisc.edu
https://www.cae.wisc.edu/mailman/listinfo/trnsys-users



 
 
************************************************************************************
This footnote confirms that this email message has been scanned by
PineApp Mail-SeCure for the presence of malicious code, vandals & computer viruses.
************************************************************************************






 
 
************************************************************************************
This footnote confirms that this email message has been scanned by
PineApp Mail-SeCure for the presence of malicious code, vandals & computer viruses.
************************************************************************************







More information about the TRNSYS-users mailing list