Discussion Closed This discussion was created more than 6 months ago and has been closed. To start a new discussion with a link back to this one, click here.

Connection between NIST REFPROP and comsol

Please login with a confirmed email address before reporting spam

I am using comsol 4.2a vesrion for modelling hydrogen storage. Can I connect NISTREFPROP to comesol like matlab?

9 Replies Last Post 2014年2月28日 GMT-5 07:20
Jim Freels mechanical side of nuclear engineering, multiphysics analysis, COMSOL specialist

Please login with a confirmed email address before reporting spam

Posted: 1 decade ago 2012年2月6日 GMT-5 21:14
Interesting that you would ask this question. I am in the process of interfacing several fluid properties from NIST REFPROP into COMSOL material libraries. To my knowledge, there is no direct link available. One must generate tables in a file and read it in to create the local libraries.
Interesting that you would ask this question. I am in the process of interfacing several fluid properties from NIST REFPROP into COMSOL material libraries. To my knowledge, there is no direct link available. One must generate tables in a file and read it in to create the local libraries.

Please login with a confirmed email address before reporting spam

Posted: 1 decade ago 2012年2月6日 GMT-5 23:14
thanks for your reply.... please tell me about the implementation of NIST REFPROP data table in to comsol material libraries.
thanks for your reply.... please tell me about the implementation of NIST REFPROP data table in to comsol material libraries.

Jim Freels mechanical side of nuclear engineering, multiphysics analysis, COMSOL specialist

Please login with a confirmed email address before reporting spam

Posted: 1 decade ago 2012年2月7日 GMT-5 22:13
As stated in the previous post, this can be done using 2D interpolation tables. How to do this is described in the COMSOL documentation. We are working on a direct function call to the NIST source code (written in FORTRAN) that can be implemented into COMSOL via MATLAB. Such a direct implementation should be much slower and cpu intensive than the aforementioned interpolation tables, but more accurate if need be.
As stated in the previous post, this can be done using 2D interpolation tables. How to do this is described in the COMSOL documentation. We are working on a direct function call to the NIST source code (written in FORTRAN) that can be implemented into COMSOL via MATLAB. Such a direct implementation should be much slower and cpu intensive than the aforementioned interpolation tables, but more accurate if need be.

Please login with a confirmed email address before reporting spam

Posted: 1 decade ago 2012年2月28日 GMT-5 11:18
hi,

i tried to connect comsol with NIST REFPROP through matlab, but it shows the following error,


Error using refpropm
Too few input arguments, should be 6 or more
- Function: dens123


can you help me to resolve this error?
hi, i tried to connect comsol with NIST REFPROP through matlab, but it shows the following error, Error using refpropm Too few input arguments, should be 6 or more - Function: dens123 can you help me to resolve this error?

Please login with a confirmed email address before reporting spam

Posted: 1 decade ago 2012年3月2日 GMT-5 06:31
What exactly are the steps you have taken to implement this? It is my understanding that one must use the MEX function in MATLAB to implement a FORTRAN code. Is this what you have done?
What exactly are the steps you have taken to implement this? It is my understanding that one must use the MEX function in MATLAB to implement a FORTRAN code. Is this what you have done?

Please login with a confirmed email address before reporting spam

Posted: 1 decade ago 2012年3月2日 GMT-5 10:14
The connection between matlab and NISTREFPROP is fine now. Because matlab will provide the density values from NISTREFPROP If I give the command

(D=refpropm('D','T','P','hydrogen.fld')in matlab.

My aim is to get the real gas parameters of hydrogen gas from NISTREFPROP with different temperature and pressure. The variables such as pressure and temperature will provided by comsol. Matlab have to call the parameters from NISTREFPROP using this this variables.

The following step are used for this implementation
1. Opened comsol 4.2a with matlab.
2. Defined a function in comsol as a matlab function.
Eg: function name (P,T)

3. Implement function name with argument in appropriate node.

4. Run


Error using refpropm
Too few input arguments, should be 6 or more
- Function: dens123
The connection between matlab and NISTREFPROP is fine now. Because matlab will provide the density values from NISTREFPROP If I give the command (D=refpropm('D','T','P','hydrogen.fld')in matlab. My aim is to get the real gas parameters of hydrogen gas from NISTREFPROP with different temperature and pressure. The variables such as pressure and temperature will provided by comsol. Matlab have to call the parameters from NISTREFPROP using this this variables. The following step are used for this implementation 1. Opened comsol 4.2a with matlab. 2. Defined a function in comsol as a matlab function. Eg: function name (P,T) 3. Implement function name with argument in appropriate node. 4. Run Error using refpropm Too few input arguments, should be 6 or more - Function: dens123

Please login with a confirmed email address before reporting spam

Posted: 1 decade ago 2012年4月19日 GMT-4 15:55
Hi,

I try to use NIST REFPROP and COMSOL 4.2a.

It's work when i do a simple thing like
Prop_comsol(273,600e3) who is a fonction who call Prop=property('H','P',A,'Q',B,'R22')

But my probleme is when i want to use this fonction with for exemple T (who is a variable of the heat transfert module) like:
Prop_comsol(T,600e3) it's doesnt work !

I dont know why but when the variable is from COMSOL solver (i try x or t for exemple) it's doesnt work ...

Do you succeded in your test ?

Thanks
Hi, I try to use NIST REFPROP and COMSOL 4.2a. It's work when i do a simple thing like Prop_comsol(273,600e3) who is a fonction who call Prop=property('H','P',A,'Q',B,'R22') But my probleme is when i want to use this fonction with for exemple T (who is a variable of the heat transfert module) like: Prop_comsol(T,600e3) it's doesnt work ! I dont know why but when the variable is from COMSOL solver (i try x or t for exemple) it's doesnt work ... Do you succeded in your test ? Thanks

Please login with a confirmed email address before reporting spam

Posted: 1 decade ago 2014年2月28日 GMT-5 04:48
can any one tell me the detail code to link Nist Refprop to Matlab to access R134a Properties
can any one tell me the detail code to link Nist Refprop to Matlab to access R134a Properties

Please login with a confirmed email address before reporting spam

Posted: 1 decade ago 2014年2月28日 GMT-5 07:20
I have been able to successfully link NIST REFPROP to Matlab and in turn use it in COMSOL. For a point of reference, I am using the FORTRAN version of REFPROP. In order for this to work, one must slightly modify the FORTRAN code in order to create a Matlab function that calls the code. This process is demonstrated in the examples of Matlab.

Next you use this newly created Matlab function in COMSOL. The issue now becomes the fact that if you try to obtain properties from NIST using a general variable in COMSOL like function(T,p), COMSOL sends these variables as matrices. The NIST code is written for a single input and thus you will get errors. From here, you have a few options:
1. Create another function that calls your NIST to Matlab function and runs the matrix through a series of for loops.
2. Alter the NIST FORTRAN code to accept an arbitrary sized matrix for input instead of a single value
3. Create a matrix of x number of values within the limits you expect to see in your simulation and import that as a definition for your properties. COMSOL will interpolate between your data points.
I have been able to successfully link NIST REFPROP to Matlab and in turn use it in COMSOL. For a point of reference, I am using the FORTRAN version of REFPROP. In order for this to work, one must slightly modify the FORTRAN code in order to create a Matlab function that calls the code. This process is demonstrated in the examples of Matlab. Next you use this newly created Matlab function in COMSOL. The issue now becomes the fact that if you try to obtain properties from NIST using a general variable in COMSOL like function(T,p), COMSOL sends these variables as matrices. The NIST code is written for a single input and thus you will get errors. From here, you have a few options: 1. Create another function that calls your NIST to Matlab function and runs the matrix through a series of for loops. 2. Alter the NIST FORTRAN code to accept an arbitrary sized matrix for input instead of a single value 3. Create a matrix of x number of values within the limits you expect to see in your simulation and import that as a definition for your properties. COMSOL will interpolate between your data points.

Note that while COMSOL employees may participate in the discussion forum, COMSOL® software users who are on-subscription should submit their questions via the Support Center for a more comprehensive response from the Technical Support team.