Python Script for Stellar Model Calibration and Evolution with PYSEP

This script uses PYSEP, a Python package for stellar evolution, to calibrate and evolve stellar models using OPAL and OPLIB opacity tables. It involves the creation of stellar models with specific configurations, calibrates them using solar calibration techniques, and then evolves these models. The script showcases the process of setting up, calibrating, and evolving stellar models comprehensively.

from pysep.dsep import stellarModel as sm
from pysep.io.nml.control.defaults import solar
from pysep.io.nml.physics.defaults import phys1
from pysep.opac.opal.defaults import GS98hz
from pysep.prems.defaults import m100_GS98
from pysep.dm.filetypes import opacf_file
 
from pysep.dsep.calibrate import basic_solar_calib
 
def main():
    OPALControl = solar.copy()
    OPALControl[0]['rsclz'] = 0.017
    OPALModel = sm("OPALModel/", OPALControl.copy(), phys1.copy(), GS98hz, m100_GS98)
 
    OPLIBhz = opacf_file("inputs/opac/GS98_ATOMIC_opac")
    OPLIBControl = solar.copy()
    OPLIBControl[0]['rsclz'] = 0.017
    OPLIBModel = sm("OPLIBModel/", OPLIBControl.copy(), phys1.copy(), OPLIBhz, m100_GS98)
 
    print('=======================\nCALIBRATING OPAL\n========================')
    OPAL_solarX, OPAL_solarML = basic_solar_calib(OPALModel)
    print('=======================\nCALIBRATING OPLIB\n========================')
    OPLIB_solarX, OPLIB_solarML = basic_solar_calib(OPLIBModel)
 
    OPALControl[0]['rsclx'] = OPAL_solarX
    OPALControl[0]['cmixla'] = OPAL_solarML
    OPALControl[1]['cmixla'] = OPAL_solarML
 
    OPLIBControl[0]['rsclx'] = OPLIB_solarX
    OPLIBControl[0]['cmixla'] = OPLIB_solarML
    OPLIBControl[1]['cmixla'] = OPLIB_solarML
 
    OPALControl[1]['nmodls'] = 3000
    OPLIBControl[1]['nmodls'] = 3000
 
    print('=======================\nEVOLVING OPAL\n========================')
    OPALModelRun = sm("OPALModel/", OPALControl, phys1.copy(), GS98hz, m100_GS98)
    print('=======================\nEVOLVING OPLIB\n========================')
    OPLIBModelRun = sm("OPLIBModel/", OPLIBControl, phys1.copy(), OPLIBhz, m100_GS98)
 
    OPALModelRun.evolve()
    OPLIBModelRun.evolve()
 
    OPALModelRun.stash(data=True)
    OPLIBModelRun.stash(data=True)
 
 
if __name__ == "__main__":
    main()