dc electric arc

Questions and remarks about code_saturne usage
Forum rules
Please read the forum usage recommendations before posting.
Kyle
Posts: 18
Joined: Wed Jun 20, 2018 9:29 pm

Re: dc electric arc

Post by Kyle »

Here's the case I have been using. I've altered the "cs_user_initialization.f90" slightly from the original file that you sent me.

I checked a checkbox labeled "Output at start of calculation" which is unchecked by default, that may be causing the issue at time step zero.

Thanks,
Kyle
Attachments
19_PFENDER_V5.0.tar.gz
(2.45 MiB) Downloaded 299 times
Yvan Fournier
Posts: 4209
Joined: Mon Feb 20, 2012 3:25 pm

Re: dc electric arc

Post by Yvan Fournier »

Hello,

Is this the standard "pfender" setup or a modifed one (if it is the standard one, I can test directly from our test suite) ?

The option you check should work ok. Unless the electric arcs module does some really nonstandard initializations (which may be possible with rescaling aspects)...

Best regards,

Yvan
Kyle
Posts: 18
Joined: Wed Jun 20, 2018 9:29 pm

Re: dc electric arc

Post by Kyle »

Hello,

It should be very close to the standard "pfender" setup, I only made a few slight modifications that were necessary to make it run on my end.

Thanks,
Kyle
Yvan Fournier
Posts: 4209
Joined: Mon Feb 20, 2012 3:25 pm

Re: dc electric arc

Post by Yvan Fournier »

Hello,

I just ran the standard PFENDER/CASE1 case for a few iterations with version 5.3-alpha (current master) en 5.0 branch head (5.0.8-patch). At time 0, using 5.3-alpha, I have an enthalpy which ranges from 5.070e+5 to 4.075e+6, so which is not uniform. So the cs_user_initialization.f90 user subroutines seem handled in this case (cs_user_boundary_conditions.f90 has no influence here). Using 5.0, I observe the same issue as you do. So something was fixed between the 2 versions, but I need to check what. I did not check with 5.2, so you may tray that version.

Which system/exact code version are you running on ?

I do observe the zero temperature issue at time step 0 with both 5.3-alpha and 5.0, so I'll look into that.

Best regards,

Yvan
Kyle
Posts: 18
Joined: Wed Jun 20, 2018 9:29 pm

Re: dc electric arc

Post by Kyle »

Hello,

I am runnning code_saturne v5.0.8 on a VirtualMachine with Ubuntu 16.04. In the morning I will attempt to run the code on v5.2 to see if it works.

Thanks,
Kyle
Kyle
Posts: 18
Joined: Wed Jun 20, 2018 9:29 pm

Re: dc electric arc

Post by Kyle »

Hello again,

I went ahead and tried to run the pfender case on Code_Saturne v5.2.0, but the result is exactly the same. Tomorrow I will work on remaking the initialization file into a C file.

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

Re: dc electric arc

Post by rodion »

Dear Kyle,

In the file src/base/inivar.f90 you can see the line

Code: Select all

call user_initialization()
In the file src/base/cs_c_bindings.f90 you can see that this line refers to the C function, not the Fortran one.

Code: Select all

    ! Interface to C user function for initialization

    subroutine user_initialization()  &
      bind(C, name='cs_user_initialization')
      use, intrinsic :: iso_c_binding
      implicit none
    end subroutine user_initialization
Long story short, Code_Saturne in the case of electric arc simulation just does not call the function cs_user_f_initialization from the file cs_user_initialization.f90
But it does call the function from cs_user_initialization.c.

So you need either to change the file src/base/inivar.f90 and call the function cs_user_f_initialization from there or to use the file cs_user_initialization.c. for initialization.

Best regards,
Rodion
Last edited by rodion on Fri Oct 12, 2018 4:20 pm, edited 2 times in total.
Kyle
Posts: 18
Joined: Wed Jun 20, 2018 9:29 pm

Re: dc electric arc

Post by Kyle »

Dear Rodion,

I will try to change the file src/base/inivar.f90 to make it accept .f90 files, but I will also keep working on making the new .c file in case I can't get it to work.

On a side note, I tried running the case that you sent me with the cs_user_initialization.c file that you provided, but the hot column did not initialize correctly on my system; the entire volume began at a uniform 300 Kelvin. Is this perhaps a problem with running the code on a Linux system?

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

Re: dc electric arc

Post by rodion »

Dear Kyle,

The file cs_user_initialization.c I have sent you should initialize the enthalpy in the hot column with the value 0.4075e7 and the rest with 1.4e4, not the temperature. Please see the code below.

Code: Select all

if (!cs_restart_present()) {
    cs_real_t enth_fluid = 1.4e4;     /*  300K for Argon*/
    cs_real_t enth_hotcol= 0.4075e7;  /* 8000K for Argon  */
    cs_lnum_t n_cells = 0;
    cs_real_t rhotcol=3.0e-3;
    cs_lnum_t *cell_list = NULL;
    printf("Init    Fluid enthalpy = %e \n",enth_fluid);
    printf("Init HotColmn enthalpy = %e \n",enth_hotcol);
    const cs_mesh_quantities_t *fvq = cs_glob_mesh_quantities;
    const cs_real_3_t *restrict cell_cen
    = (const cs_real_3_t *restrict)fvq->cell_cen;
    cs_real_t rayo;

    int iel = 0;
    for (iel = 0; iel < cs_glob_mesh->n_cells; iel++) {
      rayo=sqrt(cell_cen[iel][0]*cell_cen[iel][0]+cell_cen[iel][1]*cell_cen[iel][1]);
      if (rayo<rhotcol) {
        CS_F_(h)->val[iel] = enth_hotcol;
      } else {
        CS_F_(h)->val[iel] = enth_fluid; 
      }
    }
 }
Temperature is not initialized, it is computed by Code_Saturne using the data from the file dp_ELE. So I have no idea what is happening with temperature in your simulation. Probably you need to turn off the output of "boundary_temperature" in the tab "Surface solution control"

You can track the process of enthalpy initialization through the output window by printing things like

Code: Select all

printf("Init    Fluid enthalpy = %e \n",enth_fluid);
printf("Init HotColmn enthalpy = %e \n",enth_hotcol);
Best regards,
Rodion
Last edited by rodion on Fri Oct 12, 2018 4:20 pm, edited 1 time in total.
Kyle
Posts: 18
Joined: Wed Jun 20, 2018 9:29 pm

Re: dc electric arc

Post by Kyle »

Hello again,

How exactly do I modify the inivar.f90 file to call the function cs_user_f_initialization? It appears to already do so in the following section of code, maybe there is an error in that section?

Code: Select all

if (ippmod(iphpar).eq.0) then

  call cs_user_f_initialization(nvar, nscal, dt)

  !     Avec l'interface, il peut y avoir eu initialisation,
  !       meme si usiniv n'est pas utilise.
  if (isuite.eq.0 .and. iihmpr.eq.1) then
    iusini = 1
  endif

else

  ! ON FAIT DE LA PHYSIQUE PARTICULIERE
  !   On pourrait remonter la partie init non utilisateur de ppiniv avant lecamo
  !     dans iniva0, mais il faudrait quand meme conserver ici l'appel a
  !     ppiniv car il encapsule les appels aux ss pgm utilisateur similaires a
  !     usiniv.

  iusini = 1

  call ppiniv(nvar, nscal, dt)

  if (ippmod(icompf).ge.0.and.(    isuite.eq.0                 &
                               .or.isuite.eq.1.and.ileaux.eq.0)) then

    if (     ithvar.ne. 60000.and.ithvar.ne.100000                    &
        .and.ithvar.ne.140000.and.ithvar.ne.150000.and.ithvar.ne.210000) then
        write(nfecra,1000) ithvar
        iok = iok + 1
    endif

    ivoid = -1
    call cs_cf_thermo(ithvar, ivoid,  rvoid, rvoid, rvoid, vvoid)

  endif

endif

call user_initialization()
From what I can tell, the "if" statement that contains the call [ if(ippmod(iphpar).eq.0) ] is only active when no specific physics module is chosen, which is not the case since we are using the electric module. Would removing this "if" statement fix the problem, or is there more that needs to be changed?

I'd rather not have to reinstall a new code_saturne build every time I wanted to test out an edit, otherwise I would solve this with trial and error.

Thanks,
Kyle
Post Reply