Tgas returning 0 when run in C for collapse test

22 views
Skip to first unread message

Ciara O Sullivan

unread,
May 18, 2022, 7:08:16 AM5/18/22
to KROMEusers
Hi,
I am currently running the test 'collapse' in C alongside the fortran. I have managed to get the code to compile and run but when the C test is run the Tgas that is output is always equal to zero, while the fortran test outputs various non-zero values for Tgas. I have found that when I remove the compressional heating from the options.opt file I get fairly similar non-zero values for the Tgas from both the C and the fortran tests, though I still need to take a closer look at the values to confirm this.
 Is it possible the Tgas returning as zero from the C test is an output error caused within krome? Any solutions you can suggest to this problem would be greatly appreciated. I have included the testC.c file that I created for the collapse test if that helps. Looking forward to hearing from you.
Cheers,
Ciara O' Sullivan
testC.c

tommaso grassi

unread,
May 18, 2022, 8:07:32 AM5/18/22
to KROMEusers
Hi Ciara,

thanks for using KROME.

The problem is related to the user_tff variable that is probably not correctly passed in C.
We did it originally to speed up the code (the free-fall time can be computed once at the beginning of every time-step in the test main code).
I wrote a different version of the compressional heating routine that computes the free-fall time inside KROME.
It is slightly slower but should be a viable workaround to your problem.
Let me know if it works.

cheers,
-tg

Just replace the original function with this:
  function heat_compress(n, Tgas)
    use krome_user_commons
    use krome_commons
    use krome_constants
    use krome_subs
    use krome_getphys
    real*8::heat_compress,n(:), dd, Tgas, tff, m(nspec)

    dd = sum(n(1:nmols)) !total number density

    m = get_mass()
    rho = sum(n(1:nmols) *m(1:nmols))
    tff = sqrt(3*pi / 32. / gravity / rho)
   
    !COMPRESSIONAL HEATING
    heat_compress = dd * boltzmann_erg * Tgas / tff !erg/s/cm3

  end function heat_compress

Ciara O Sullivan

unread,
May 18, 2022, 8:35:03 AM5/18/22
to KROMEusers
Hi Tommas,
Thanks for getting back so quick. The new heat_compress function has fixed the problem, both tests now seem to be running properly. Thanks so much for the help.
Cheers,
Ciara

Reply all
Reply to author
Forward
0 new messages