Hello,
I am solving the enthalpy as thermal scalar. Temperature is provided through the usthht.f90 routine.
I am using the cs_user_physical_properties.f90 to define the density, and I would like to use the temperature to calculate the density. My question is: how do I call the temperature "scalar"? I.e. what is the name I have to use in the field_get_val_s(ivarfl(.....), temperature)?
By the way, using Paraview I cannot manage to visualize the temperature contour (when enthalpy is solved). Thus I cannot check if my H-->T definition in correct. Is there a way to post treat temperature?
Thank you in advance.
Best regards,
Daniele
call temperature when solving enthalpy thermal scalar
Forum rules
Please read the forum usage recommendations before posting.
Please read the forum usage recommendations before posting.
-
- Posts: 4208
- Joined: Mon Feb 20, 2012 3:25 pm
Re: call temperature when solving enthalpy thermal scalar
Hello,
When using a specific physical modela (such as combustion ,electric arcs, ...), using enthalpy, the temperature is usually defined as a physical property.
With fully "user" setup, this is not automatic, so my recommendation would be to define a temperature property (first check in setup.log that a temperature field does not already exist).
You can then use the usthht.f90 subroutine to compute the temperature based on the enthalpy, doing this at each time step (or first in cs_user_initialization, then in cs_user_extra_operations).
A simpler solution may be simply in cs_user_physical_properties.f90 to allocate a temporary array, call usthht.f90 to convert from enthalpy to temperature in this temporary array, and use that temperature value to compute your properties. It has the advantage of doing everything at tha same place, avoidind tn+1/tn update issues.
Regards,
Yvan
When using a specific physical modela (such as combustion ,electric arcs, ...), using enthalpy, the temperature is usually defined as a physical property.
With fully "user" setup, this is not automatic, so my recommendation would be to define a temperature property (first check in setup.log that a temperature field does not already exist).
You can then use the usthht.f90 subroutine to compute the temperature based on the enthalpy, doing this at each time step (or first in cs_user_initialization, then in cs_user_extra_operations).
A simpler solution may be simply in cs_user_physical_properties.f90 to allocate a temporary array, call usthht.f90 to convert from enthalpy to temperature in this temporary array, and use that temperature value to compute your properties. It has the advantage of doing everything at tha same place, avoidind tn+1/tn update issues.
Regards,
Yvan
Re: call temperature when solving enthalpy thermal scalar
Dear Yvan,
Thank you for your help.
I followed your suggestion of calling the usthht.f90 inside the cs_user_physical_properties.f90. I have an error at the first iteration:
SIGSEGV signal (forbidden memory area access) intercepted!
Call stack:
1: 0x401421 <usthht_+0x5> (cs_solver)
2: 0x401524 <usphyv_+0x78> (cs_solver)
3: 0x2ac0816885b3 <phyvar_+0x18b> (libsaturne.so.0)
.....
I wonder if it could be a problem of order of execution of routines. I mean, if the cs_user_physical_properties is executed before the usthht that could cause the problem since temperature field is not available...
I would like to write a condition such as:
if (nr_iteration < 2)
rho = 1000
else
call usthht(1,enthalpy,temperature)
rho=A+B*temperature
But I don’t know how to call the iteration number. Do you think this could solve the problem?
For the temperature field to be post-treated, I had a look but it is not clear for me how to define a new property (with cs_user_parameter I guess). Could you give me a hint?
Thanks in advance.
Regards,
Daniele
Thank you for your help.
I followed your suggestion of calling the usthht.f90 inside the cs_user_physical_properties.f90. I have an error at the first iteration:
SIGSEGV signal (forbidden memory area access) intercepted!
Call stack:
1: 0x401421 <usthht_+0x5> (cs_solver)
2: 0x401524 <usphyv_+0x78> (cs_solver)
3: 0x2ac0816885b3 <phyvar_+0x18b> (libsaturne.so.0)
.....
I wonder if it could be a problem of order of execution of routines. I mean, if the cs_user_physical_properties is executed before the usthht that could cause the problem since temperature field is not available...
I would like to write a condition such as:
if (nr_iteration < 2)
rho = 1000
else
call usthht(1,enthalpy,temperature)
rho=A+B*temperature
But I don’t know how to call the iteration number. Do you think this could solve the problem?
For the temperature field to be post-treated, I had a look but it is not clear for me how to define a new property (with cs_user_parameter I guess). Could you give me a hint?
Thanks in advance.
Regards,
Daniele
-
- Posts: 4208
- Joined: Mon Feb 20, 2012 3:25 pm
Re: call temperature when solving enthalpy thermal scalar
Hello,
How do you allocate your temporary array ?
Could you post the whole file instead of just a snippet ?
Regards,
Yvan
How do you allocate your temporary array ?
Could you post the whole file instead of just a snippet ?
Regards,
Yvan
Re: call temperature when solving enthalpy thermal scalar
Hello,
You can find in the attachement the way I wrote the subroutine and I call the usthht.
Thanks a lot in advance.
Best regards,
daniele
You can find in the attachement the way I wrote the subroutine and I call the usthht.
Thanks a lot in advance.
Best regards,
daniele
- Attachments
-
- test_rho.f90
- (5.81 KiB) Downloaded 339 times
-
- Posts: 4208
- Joined: Mon Feb 20, 2012 3:25 pm
Re: call temperature when solving enthalpy thermal scalar
Hello,
You do not allocate the temperature array, so it is to be expected that you have a crash (having incorrect values and no crash would be worse).
you need something like:
Regards,
Yvan
You do not allocate the temperature array, so it is to be expected that you have a crash (having incorrect values and no crash would be worse).
you need something like:
and:allocate(temp(ncelet))
when you are finished. You may check the provided user examples for many more examples.deallocate(temp)
Regards,
Yvan
Re: call temperature when solving enthalpy thermal scalar
Hello,
The density definition as a function of temperature is ok now.
But I still miss the way to visualize the temperature through a user defined new field.
I created a new field through the field_create(...) in the cs_user_parameter routine, and I can see it in the setup.log. But what is the function to be used to fill the new field with the desired array (temperature in this case)?
Moreover, I wonder why other fields such as density are present in setup.log but they are not available in the Paraview list...
Thank you in advance.
Regards,
Daniele
The density definition as a function of temperature is ok now.
But I still miss the way to visualize the temperature through a user defined new field.
I created a new field through the field_create(...) in the cs_user_parameter routine, and I can see it in the setup.log. But what is the function to be used to fill the new field with the desired array (temperature in this case)?
Moreover, I wonder why other fields such as density are present in setup.log but they are not available in the Paraview list...
Thank you in advance.
Regards,
Daniele
-
- Posts: 4208
- Joined: Mon Feb 20, 2012 3:25 pm
Re: call temperature when solving enthalpy thermal scalar
Hello,
When creating a new field in cs_user_parameters.c/cs_user_model or cs_user_parameters... by default, both logging (listing) and postprocessing are activated for solved variables, only logging for properties. This is to avoid generating too large postprocessing outputs when most users only check some variables.
To add postprocessing to the temperature field, in cs_user_parameters.c, use:
You can also do this in Fortran (see examples in cs_user-parameters-output.f90).
Best regards,
Yvan
When creating a new field in cs_user_parameters.c/cs_user_model or cs_user_parameters... by default, both logging (listing) and postprocessing are activated for solved variables, only logging for properties. This is to avoid generating too large postprocessing outputs when most users only check some variables.
To add postprocessing to the temperature field, in cs_user_parameters.c, use:
Where f_id is the id of the field you added (obtained in setup.log, or through "cs_field_by_name").cs_field_set_key_int(f_id, cs_field_key_id("post_vis"), 1);
You can also do this in Fortran (see examples in cs_user-parameters-output.f90).
Best regards,
Yvan
Re: call temperature when solving enthalpy thermal scalar
Hello everyone,
Could you please explain three details:
1. What is the essential difference between two ways of creating the temperature field?
a. call add_property_field('temperature', 'Temperature', itemp)
b. itycat = FIELD_INTENSIVE + FIELD_PROPERTY
ityloc = 1 !cells
idim1 = 3
ilved = .true.
inoprv = .false.
call field_create('temperature', itycat, ityloc, idim1, ilved, inoprv, f_id)
Maybe there is some difference in output or in access to the field in the code?
2.Is this way to get access to the temperature field valid?
call field_get_val_s(iprpfl(itemp), cpro_temp)
3. If the thermal scalar is temperature (itherm=1) for the case of electric arc simulation, how is the variable "enthalpy" ivarfl(isca(ihm)) converted to the variable "temperature" ivarfl(isca(iscalt)) inside of electrodes where dp_ELE doesn't work?
And is it correct to use temperature as a thermal scalar for electric arc simulation?
Best regards,
Rodion
Could you please explain three details:
1. What is the essential difference between two ways of creating the temperature field?
a. call add_property_field('temperature', 'Temperature', itemp)
b. itycat = FIELD_INTENSIVE + FIELD_PROPERTY
ityloc = 1 !cells
idim1 = 3
ilved = .true.
inoprv = .false.
call field_create('temperature', itycat, ityloc, idim1, ilved, inoprv, f_id)
Maybe there is some difference in output or in access to the field in the code?
2.Is this way to get access to the temperature field valid?
call field_get_val_s(iprpfl(itemp), cpro_temp)
3. If the thermal scalar is temperature (itherm=1) for the case of electric arc simulation, how is the variable "enthalpy" ivarfl(isca(ihm)) converted to the variable "temperature" ivarfl(isca(iscalt)) inside of electrodes where dp_ELE doesn't work?
And is it correct to use temperature as a thermal scalar for electric arc simulation?
Best regards,
Rodion
Re: call temperature when solving enthalpy thermal scalar
Hi,
for electric arc you can only use enthalpy. Temperature is only for radiative properties (if needed) and post-traitment. To use electric arc, the only possible way is to use "dp_ELE". You can't use usthht.f90 or cs_user_physical_properties.f90. Properties are defined in dp_ELE input file only yet.
Best regards,
Cyril
for electric arc you can only use enthalpy. Temperature is only for radiative properties (if needed) and post-traitment. To use electric arc, the only possible way is to use "dp_ELE". You can't use usthht.f90 or cs_user_physical_properties.f90. Properties are defined in dp_ELE input file only yet.
Best regards,
Cyril