user_physical properties.f90

Questions and remarks about code_saturne usage
Forum rules
Please read the forum usage recommendations before posting.
frpageot
Posts: 85
Joined: Wed Mar 21, 2012 1:10 pm

user_physical properties.f90

Post by frpageot »

Hello,

I would like to use user physical properties in my simulations based on the mix of 2 gazes (actually vapor and air) which properties are defined according to temperature and molecular fraction. To do so, I defined a fraction as a user scalar, and I use the user_physical properties.f90 in the SRC folder to define the appropriates properties equations. but it was not working. Unable to find the root cause of the message : "Fortran pointer of rank 1 requested for values of field "velocity", which have rank 2.". I decided to use the base one, only turning one false into a true, just to see if in this case I have the same error message, which is the case. I am not used enough to code to understand wher ethe problem comes from, but it seems that it is related to the fact that the velocity field and the pointer does not have the same definition, am I right ? What can I do to solve this ? Thanks.
Fred
Xubuntu 16.04 / CS5.0
Yvan Fournier
Posts: 4081
Joined: Mon Feb 20, 2012 3:25 pm

Re: user_physical properties.f90

Post by Yvan Fournier »

Hello,

The message is related to trying to access a field of vectors as a field of scalars, or vice versa.

At the root of this, you probably tried accessing the wrong fields, so you should check your field numbering (and be careful with the ivarfl() indirection, or use field_get_val_s_by_name / field_get_val_v_by name for simplicity).

Regards,

Yvan
frpageot
Posts: 85
Joined: Wed Mar 21, 2012 1:10 pm

Re: user_physical properties.f90

Post by frpageot »

Hello,

Thanks you Yvan as usual you pointed out the problem. I used field_get_key_id, while I should use field_get_key_int. At least with this instruction I do not have any problem as described above.
Fred
Xubuntu 16.04 / CS5.0
frpageot
Posts: 85
Joined: Wed Mar 21, 2012 1:10 pm

Re: user_physical properties.f90

Post by frpageot »

Hello again,

One more question. I am not sure I totally understood the scalar numbering in CS. Temperature scalar is tagged with isca(iscalt), but something I am not sure is about the second scalar numbering (molecular fraction in my case) in addition to the temperature scalar. Is it isca(2) (as if iscalt=1), or is it isca(1), considering that temperature is a scalar without specific numbering ? Thanks.
Fred
Xubuntu 16.04 / CS5.0
Yvan Fournier
Posts: 4081
Joined: Mon Feb 20, 2012 3:25 pm

Re: user_physical properties.f90

Post by Yvan Fournier »

Hello,

The numbering depends on the physical model and how many scalars you use. User-defined scalas should come first.

This is why it is recommended to use the field names. (Simply avoid using names in loops over elements (for performance reasons), by obtaining the id of a field of a given name outside a loop.

Also, info on all fields is logged in the setup.log file.

Regards,

Yvan
frpageot
Posts: 85
Joined: Wed Mar 21, 2012 1:10 pm

Re: user_physical properties.f90

Post by frpageot »

Hello,

As I told the simulation and the user physical properties I am using are to be able to have a mix of 2 different gases, one is water vapor and the other is air. i set up the user_physical properties.f90 file as this is shown in the enclosed file. I would like to have you feeling about that, not sure I did it totally right. Any help is more than welcome.

Thank you.
cs_user_physical_properties.f90
(18.72 KiB) Downloaded 236 times
Fred
Xubuntu 16.04 / CS5.0
frpageot
Posts: 85
Joined: Wed Mar 21, 2012 1:10 pm

Re: user_physical properties.f90

Post by frpageot »

Off course I am not dealing with the specific physic of this routine, but just the organization of it. I do confess that I am not really familiar with such a thing. Many thanks if one can help me.

I am just asking because when I do not use the specific physic, it is OK, when I use it, the first iteration is really long. Actually it never passes the first iteration, but without any error, just keep calculating.
Fred
Xubuntu 16.04 / CS5.0
frpageot
Posts: 85
Joined: Wed Mar 21, 2012 1:10 pm

Re: user_physical properties.f90

Post by frpageot »

OK, I will answer partially to my question. The fact is that as I am running on 16 proc, I used the parsom subroutine to compute local som of the different coefficient calculated, as shown hereafter :


! ===================================================================
! Calcul propriétés du mélange
! ===================================================================

do iel = 1, ncel
xvart = cvar_scalt(iel)
xv=cvar_scal(iel)
!
T=xvart+273.15

mu_a=(ma0+ma1*T+ma2*T**2+ma3*T**3+ma4*T**4)*1d-6
k_a=(ka0+ka1*T+ka2*T**2+ka3*T**3+ka4*T**4+ka5*T**5)*1d-3
icp_a=(ica0+ica1*T+ica2*T**2+ica3*T**3+ica4*T**4)*1d3
mu_v=(mv0+mv1*T)*1d-6
k_v=(kv0+kv1*T+kv2*T**2)*1d-3
icp_v=(icv0+icv1*T+icv2*T**2)*1d3
aa=sqrt(2.0)
phi_av=aa/4*(1+ma/mv)**(-1/2)*(1+(mu_a/mu_v)**(1/2)*(mv/ma)**(1/4))**2
phi_va=aa/4*(1+mv/ma)**(-1/2)*(1+(mu_v/mu_a)**(1/2)*(ma/mv)**(1/4))**2

if (irangp.ge.0) then
! ! call parsom(T)
call parsom(mu_a)
call parsom(k_a)
call parsom(icp_a)
call parsom(mu_v)
call parsom(k_v)
call parsom(icp_v)
call parsom(phi_av)
call parsom(phi_va)
endif


cpro_rom(iel)=pref/(const*T)*ma*(1-xv*(1-mv/ma))
cpro_viscl(iel) =((1-xv)*mu_a)/((1-xv)+xv*phi_av)+(xv*mu_v)/(xv+(1-xv)*phi_va)
cpro_cp(iel)=icp_a*(1-xv)*ma/(ma*(1-xv)+mv*xv)+icp_v*xv*mv/(ma*(1-xv)+mv*xv)
cpro_vscalt(iel)=((1-xv)*k_a)/((1-xv)+xv*phi_av)+(xv*k_v)/(xv+(1-xv)*phi_va)

enddo

As the error mentioned something related to parallel operation waiting for something (pile n°4) when I kill the process after 12 hours of calculation without any iteration out of the system :
Signal SIGTERM (terminaison) reçu.
--> calcul interrompu par l'environnement.

Pile d'appels :
1: 0x7f3e113c52a7 <__sched_yield+0x7> (libc.so.6)
2: 0x7f3e10332a4d <opal_progress+0xbd> (libmpi.so.1)
3: 0x7f3e10280285 <ompi_request_default_wait_all+0x1b5> (libmpi.so.1)
4: 0x7f3e102a5d58 <PMPI_Waitall+0xa8> (libmpi.so.1)
5: 0x7f3e11fe242f <cs_halo_sync_var+0x1bf> (libsaturne.so.0)
6: 0x7f3e12084585 <phyvar_+0x33b5> (libsaturne.so.0)
7: 0x7f3e120a7b89 <tridim_+0x1099> (libsaturne.so.0)
8: 0x7f3e11f891de <caltri_+0x301e> (libsaturne.so.0)
9: 0x7f3e11f6131e <cs_run+0x3fe> (libsaturne.so.0)
10: 0x7f3e11f60e12 <main+0x112> (libsaturne.so.0)
11: 0x7f3e1131bf45 <__libc_start_main+0xf5> (libc.so.6)
12: 0x401139 <> (cs_solver)
Fin de la pile


I decided to comment those lines related to parsom operation. The system is running now calculating at least something, but my fear is that it does not reflect the calculation as the global sum is not carried out.

Any thought on this ?
Fred
Xubuntu 16.04 / CS5.0
Yvan Fournier
Posts: 4081
Joined: Mon Feb 20, 2012 3:25 pm

Re: user_physical properties.f90

Post by Yvan Fournier »

Hello,

This may mean you have an incorrect (or badlly initialized) value one one proc. Is the case small enough to run on 1 proc for 1 or 2 times steps, for debugging ?

Regards,

Yvan
frpageot
Posts: 85
Joined: Wed Mar 21, 2012 1:10 pm

Re: user_physical properties.f90

Post by frpageot »

Hello Yvan, it depends what you call small enough : 938189 cells is small ?

I will try to run on one proc. by the way I found this thread : http://www.code-saturne.org/forum/viewt ... f=2&t=1577 where the error message is quite close. I tried to reduce my time steps, but is did not solve the problem.
Fred
Xubuntu 16.04 / CS5.0
Post Reply