rjfarmer/pyMesa

const_def.kerg.value returns incorrect value

Closed this issue · 3 comments

I am trying to read the const module of MESA to access the values defined in public/const_def.f90. Some of the values in const_def.<variable>.value appear to be wrong, e.g., Boltzmann's constant.

After installing pyMESA (fresh checkout of the repo), I tried:

import pyMesaUtils as pym

print(pym.MESA_DIR) #  correct path
print(pym.MESA_VERSION) # correct

const_lib, const_def = pym.loadMod("const")

print("Msun="+f"{const_def.Msun.value:.2e}")
print("Lsun="+f"{const_def.Lsun.value:.2e}")
print("kerg="+f"{const_def.kerg.value:.2e}")
print("boltzm="+f"{const_def.boltzm.value:.2e}")
print("secyer="+f"{const_def.secyer.value:.2e}", )
  
> Msun=1.99e+33
> Lsun=3.83e+33
> kerg=9.95e+00
> boltzm=9.95e+00
> secyer=3.16e+07

where Msun, Lsun, and secyer seem correct, but both values of Boltzmann's constant are not the expected value in erg/K.

So the quick fix is if you download and build the newest main branch (106333c) of gfort2py. I'm trying to sort a release for it with the fix but as i haven't made one for a long time lots of things have broken. So i don't know how good pyMesa will be (beyond accessing constants) at this point (gfort2py is what powers the python to fortran side of things).

False alarm turns out I forget how my test suite worked.

You just need yo update gfort2py to version 1.1.7 and everything should be working

Indeed, updating gfort2py did the trick! For now, I'm only planning to load the const module, and I am getting the correct values now:

import pyMesaUtils as pym
# print(pym.MESA_DIR) # Print MESA_DIR
print(pym.MESA_VERSION) #Print MESA version number
import gfort2py
print("gfort2py version:", gfort2py.__version__) #1.1.7
const_lib, const_def = pym.loadMod("const")
print("Msun="+f"{const_def.Msun.value:.2e}")
print("Lsun="+f"{const_def.Lsun.value:.2e}")
print("kerg="+f"{const_def.kerg.value:.2e}")
print("boltzm="+f"{const_def.boltzm.value:.2e}")
print("secyer="+f"{const_def.secyer.value:.2e}", )
15140
gfort2py version: 1.1.7
Msun=1.99e+33
Lsun=3.83e+33
kerg=1.38e-16
boltzm=1.38e-16
secyer=3.16e+07