Welcome to the TRNSYS Users Forum.
The forum is a place where people can interact and have discussions about different topics involving the use of the TRNSYS software package. Here you can post topics for discussion or questions on using TRNSYS and get advice from other users or TRNSYS experts. This forum is not intended for detailed technical support. Users should contact their distributor’s hotline for such assistance.
Some tips for success on using the forum:
- Follow the Forum Rules posted in Forum Administration.
- There are categories for different types of topics and questions. Post your topic or question into the proper category.
- Before posting a topic or question search the existing topics (and the TRNSYS Users listserv archive or Post archive) to see if a similar topic or question has already been answered.
- Use a descriptive topic name. Don’t use attention getting subjects, they don’t get attention and only annoy people.
- State the version of TRNSYS and which add-ons your are using.
- Include enough specific details for your topic of question to be answered. Just posting “Why am I getting an error?” without describing the specific error and what you are trying to do when you get the error will not receive a response that fixes your issue.
- Remember when people help you, they are doing you a favor. Be patient, help people out by posting good descriptions of what you need help with, and be polite even if a response does not solve your issue.
- Moderators may edit your post for clarity or move your topic to a more appropriate category.
Good morning,
I'm writing to seek your expertise on a coding challenge I'm facing. I'm currently working on a component that involves calling temperature values from CoolProp based on given pressure and enthalpy inputs.
However, I've encountered an issue where, when both pressure and enthalpy values don't exist in the CoolProp database, the returned temperature is infinity. To handle this scenario gracefully, I'd like to implement an if condition within my FORTRAN code.
Unfortunately, I'm unsure how to accurately define this condition. Directly checking for "T = infinity" isn't feasible in FORTRAN. I've explored the CoolProp interface and error messages, but haven't found a suitable solution yet.
I would be grateful if you could provide guidance on how to formulate the if condition to effectively identify and handle this infinity temperature issue.
Thank you for your time and assistance.
Best regards,
I've used catch-all code for illegal values in the past like
If((Temperature<=-1000000).or.(Temperature>1000000.).or.ISNAN(Temperature)) Then Call Messages(-1,'The temperature value is invalid','Fatal',getCurrentUnit(),getCurrentType()) Return End
You could also try Googling for intrinsic Fortran functions that will catch +infinity and -infinity conditions.
@a_weiss okay
i'm working on this values in certain code
nRef = 729!Air
prop(3) = 104.040
prop(2) = 9998999!Pressure (Pa)
Call CoolProp_Fluid_Properties(prop,nRef,23,iFlagr)
If (ErrorFound()) Return
Temperature = prop(1)
If((Temperature1000000.).or.ISNAN(Temperature)) Then
Call Messages(-1,'The temperature value is invalid','Fatal',getCurrentUnit(),getCurrentType())
Return
End if
open(94, file = 'results.dat', status='old', position="append")
write(94,*) Temperature+273
close(94)
Call SetOutputValue(1, Temperature) ! Enthalpy
Return
End
and i thought that the temperature value was the reason of invalid floating point, can you tell me what the reason of the error? specially these values are working correctly on online coolprop and refprop
@gehadrabee24 Try passing the pressure to CoolProp_Fluid_Properties in MPa instead of Pa. Also make sure your enthalpy is in units of kJ/kg, not J/kg. You can read more about how to use the CoolProp_Fluid_Properties routine beginning on page 7-82 of the ProgrammersGuide.pdf in the Documentation folder of your main TRNSYS directory.
Edit: The documentation in TRNSYS version 18.6 is incorrect. The units of pressure should be in MPa, not Pa.