Electrodes inside of the domain and its properties.

Questions and remarks about code_saturne usage
Forum rules
Please read the forum usage recommendations before posting.
rodion
Posts: 98
Joined: Wed Jan 11, 2017 4:13 pm

Electrodes inside of the domain and its properties.

Post by rodion »

Hello everyone,

I work on the simulation of electric arc in DC plasma torch. Could you please help me with these details:

1. My goal is to avoid direct establishing of boundary conditions at the electrode surface. So I have to involve electrodes into the simulation domain and impose its properties for the simulation.
I have files with properties of tungsten and copper (T->H, Cp, Sigma), I know its densities.
I've tried to do it, using cs_user_physical_properties.f90 and usthht.f90 (these files are in the attachment), but unfortunately, I can see only properties from dp_ELE in the postprocessing files.
How can I impose properties (temperature, specific heat, thermal and electrical conductivity) of the metals inside of electrodes using this files?
Maybe I have to edit some internal subroutines (elthht or cs_elec_model.c for instance)?

2. Does the following line add temperature field in the postprocessing files for visualisation by default? And where should I add this line?
call add_property_field('temperature', 'Temperature', itemp)

Thanks in advance.
Best regards,
Rodion
Attachments
cs_user_physical_properties.f90
(16.11 KiB) Downloaded 476 times
usthht.f90
(5.94 KiB) Downloaded 460 times
Yvan Fournier
Posts: 4208
Joined: Mon Feb 20, 2012 3:25 pm

Re: Electrodes inside of the domain and its properties.

Post by Yvan Fournier »

Hello,

I'll let others answer 1).

For 2), the temperature (and temperature-enthalpy conversion) is already defined in the electric arcs module, so the field already exists. If you change the way properties are computed, you may also need to adapt the temperature-enthalpy conversion, but all of this is defined in src/elec/cs_elec_model.c.

Regards,

Yvan
rodion
Posts: 98
Joined: Wed Jan 11, 2017 4:13 pm

Re: Electrodes inside of the domain and its properties.

Post by rodion »

Thank you for your answer, Yvan.

1. Thank you for any assistance with electrodes properties. It is quiet complicated for me now. I hope someone will be able to explain.

2. Unfortunately I can see temperature only at the boundary of the domain, and not for the internal cells. Temperature in GUI in "Volume solution control" is checked but it doesn't work.
Could you please explain, how can I obtain the pointer to the temperature for the case of electric arc simulation?

3. By the way, Head Loss doesn't work in CS 4.3 (Windows 7 Prof SP1 x64). If I check "Head Loss" in "Volume region definition" corresponding item doesn't appear. It works for CS 4.2, so I've decided to create .xml file with predefined head loss and open it in CS 4.3. But I've got this:

Traceback (most recent call last):
File "lib/python2.7/site-packages\code_saturne\Base\MainView.py", line 1186, in displayNewPage
File "lib/python2.7/site-packages\code_saturne\Base\BrowserView.py", line 579, in display
File "lib/python2.7/site-packages\code_saturne\Base\Toolbox.py", line 134, in displaySelectedPage
File "lib/python2.7/site-packages\code_saturne\Pages\HeadLossesView.py", line 192, in __init__
File "lib/python2.7/site-packages\code_saturne\Pages\HeadLossesModel.py", line 74, in __init__
File "lib/python2.7/site-packages\code_saturne\Base\XMLvariables.py", line 281, in _wrapper3
File "lib/python2.7/site-packages\code_saturne\Pages\HeadLossesModel.py", line 107, in getNameAndLocalizationZone
KeyError: 'head_losses'

Maybe it is a malfunction?

4. Initialization.
I've tried to start the case with hot colomn at the central axis through GUI:
enthalpy = 14000.;
if (x*x+y*y<=0.5e-3*0.5e-3)
enthalpy = 0.59663E+07;
It doesn't work for both CS 4.2 and 4.3. In output it gives uniform distribution of enthalpy=5.074e+05. Without electric arc simulation thermal initialization through GUI works good.

And I've tried to do it through the subroutine cs_user_initialization:
subroutine cs_user_initialization (nvar, nscal, dt)
use paramx
use numvar
use entsor
use optcal
use cstphy
use parall
use period
use mesh
use field

implicit none
integer nvar , nscal
double precision dt(ncelet)

integer iel
integer, allocatable, dimension(:) :: lstelt
double precision, dimension(:), pointer :: cvar_scalt
double precision rayo

allocate(lstelt(ncel))
call field_get_val_s(ivarfl(isca(iscalt)), cvar_scalt)
do iel = 1, ncel
cvar_scalt(iel) = 14000.0
rayo = sqrt(xyzcen(1,iel)*xyzcen(1,iel)+xyzcen(2,iel)*xyzcen(2,iel))
if(rayo.lt.0.3d-3) cvar_scalt(iel) = 0.40750e+07
enddo
deallocate(lstelt)

return
end subroutine
cs_user_initialization

It works for CS 4.2, but for CS 4.3 it is not even compiled because of problems with use of modules such as numvar or optcal (errors description is below). For PFENDER_CASE1 I've got the same problem. Compile log is in the attachment. While for the subroutine ustsnv in cs_user_source_terms.f90 the same lines works without problems.

use numvar
1
Error: 'cs_user_initialization' of module 'numvar', imported at (1), is also the name of the current program unit
use optcal
1
Error: 'cs_user_initialization' of module 'optcal', imported at (1), is also the name of the current program unit

Could you please take a look on it and explain what am I doing wrong?

Best regards,
Rodion
Attachments
Pfender_compile.log
(7.75 KiB) Downloaded 498 times
Yvan Fournier
Posts: 4208
Joined: Mon Feb 20, 2012 3:25 pm

Re: Electrodes inside of the domain and its properties.

Post by Yvan Fournier »

Hello,

Here are some partial answers:

2) this might be a bug due to changes in handling of defaults in postprocessing of properties. You should be able to force the output using:

Code: Select all

integer :: f_id, iflpst
in the variables definition section, then

Code: Select all

call field_get_id_try('temperature', f_id)
call field_get_key_int(f_id, keyvis, iflpst)
iflpst = ior(iflpst, 1)
call field_set_key_int(f_id, keyvis, iflpst)
3) Do you get any messages in a terminal in CS 4.3 when checking "Head Loss" ? I don't reproduce this on Linux. Also the GUI should update a file generated in version 4.2 automatically, so this seems strange. Could you post the xml file you generated in 4.2 ?
I hope it is not a Windows-specific issue, as that would make it harder to debug...

4) I'll check, but it is possible that some specific physics overwrite the GUI-defined user initialization (which is not the best initialization order, but I'll check with Cyril if he remembers there being a good reason for this.

In any case, user subroutine signatures may change from one version to another, so it is best not to use the same file, but start from the files in SRC/REFERENCE for a case created with a given version and place your code in there.

On Linux, I also often use a tool such as "meld" to update an old file by merging it with the new REFERENCE, but I don't know what equivalent tool you may have on Windows.

Best regards,

Yvan
rodion
Posts: 98
Joined: Wed Jan 11, 2017 4:13 pm

Re: Electrodes inside of the domain and its properties.

Post by rodion »

Thank you for your answer, Yvan.

2. Thank you for the code. Could you please provide a name of subroutine or file where I should locate it?

3. Yes, I get the message in a terminal in CS 4.3 when checking "Head Loss". It is:
Traceback (most recent call last):
File "lib/python2.7/site-packages\code_saturne\Base\MainView.py", line 1186, in displayNewPage
File "lib/python2.7/site-packages\code_saturne\Base\BrowserView.py", line 579, in display
File "lib/python2.7/site-packages\code_saturne\Base\Toolbox.py", line 134, in displaySelectedPage
File "lib/python2.7/site-packages\code_saturne\Pages\HeadLossesView.py", line 192, in __init__
File "lib/python2.7/site-packages\code_saturne\Pages\HeadLossesModel.py", line 74, in __init__
File "lib/python2.7/site-packages\code_saturne\Base\XMLvariables.py", line 281, in _wrapper3
File "lib/python2.7/site-packages\code_saturne\Pages\HeadLossesModel.py", line 107, in getNameAndLocalizationZone
KeyError: 'head_losses'

Please find thexml file in the attachment. When I use it for CS4.3, corresponding item in the GUI appears but is not active.

4. GUI-defined user initialization works for the case without electric arc simulation, but doesn't work for the case with electric arc simulation.
So I have decided to take the file cs_user_initialization.f90 from SRC/REFERENCE for a case created with CS 4.3 and add my code into this file. Please find it in the attachment. But it doesn't pass the compilation. Please find the compile log in the attachment.
But this file cs_user_initialization.f90 for CS 4.3 works with CS 4.2.

Best regards,
Rodion
Attachments
compile.log
(3.71 KiB) Downloaded 471 times
cs_user_initialization.f90
(4.87 KiB) Downloaded 501 times
CaseWithHeadLossFromCS4.2.xml
(16.59 KiB) Downloaded 652 times
Yvan Fournier
Posts: 4208
Joined: Mon Feb 20, 2012 3:25 pm

Re: Electrodes inside of the domain and its properties.

Post by Yvan Fournier »

Hello;

For 2), I forgot to specify the place to add that code is in the usipes subroutine, in the cs_user_parameters.f90 file (a C alternative in cs_user_parameters.c is possible).

For the head losses, I'll try to check this by early next week.

Best regards,

Yvan
rodion
Posts: 98
Joined: Wed Jan 11, 2017 4:13 pm

Re: Electrodes inside of the domain and its properties.

Post by rodion »

Thank you, Yvan.

Look forward to further discussion.

Best regards,
Rodion
rodion
Posts: 98
Joined: Wed Jan 11, 2017 4:13 pm

Re: Electrodes inside of the domain and its properties.

Post by rodion »

Dear Yvan

I have tried to implement your code in cs_user_parameters.f90 (please find the file attached), but in the postprocessing folder I found two fields "temperature" and "Temperature" only for the boundary surface and not for the fluid domain. It mean that I can't visualize temperature inside of the domain.

I made a screen output of iflpst before and after the line

Code: Select all

iflpst = ior(iflpst, 1)
And I found that iflpst equals 1 before and after this codeline.

Described above actions performed in CS 4.2.

Best regards,
Rodion
Attachments
cs_user_parameters.f90
(71.25 KiB) Downloaded 513 times
Yvan Fournier
Posts: 4208
Joined: Mon Feb 20, 2012 3:25 pm

Re: Electrodes inside of the domain and its properties.

Post by Yvan Fournier »

Hello,

Could you also post the other recommended setup and log files (xml, listing, *.log).

Regards,

Yvan
rodion
Posts: 98
Joined: Wed Jan 11, 2017 4:13 pm

Re: Electrodes inside of the domain and its properties.

Post by rodion »

Thank you for your answer, Yvan.

I found that if I uncheck the check box "Boundary temperature" for "Surface solution control" in GUI, the temperature field for fluid domain appears in the visualization in ParaView.
In the file RESULTS.case I have found following lines:
scalar per element: 1 temperature results.temperature.*****
scalar per element: 1 Temperature results.temperature.*****
So as far as I can see Code_Saturne overwrote the volume data by the surface data and then ParaView visualized the surface data under the name of volume data.

Anyway, I have attached the listing, log files and xml file for the case in which both temperature field were visualized at the boundary surface only.

Best regards,
Rodion
Attachments
xml_logs_listing.rar
(29.63 KiB) Downloaded 473 times
Post Reply