Python Script for Testing Stellar Models with DSEP

This Python script is designed to test the Dartmouth Stellar Evolution Program (DSEP) by loading and applying different atmospheric boundary conditions. It dynamically imports modules for handling varying types of boundary condition files, opacities, stellar masses, and physical constants. The script allows users to specify paths to different boundary condition tables via command-line arguments, creates a stellar model with these conditions, evolves it, and saves the output. This is useful for astrophysicists and researchers focusing on stellar evolution simulations.

#!/usr/bin/env python3
 
from pysep.dsep import stellarModel as sm
 
from pysep.dm.filetypes import bcphx95_file
from pysep.dm.filetypes import bcphx96_file
from pysep.dm.filetypes import bcphx97_file
from pysep.dm.filetypes import bcphx98_file
from pysep.dm.filetypes import bcphx99_file
 
from pysep.opac.opal.defaults import GS98hz
from pysep.prems.defaults import m080_GS98
from pysep.prems.defaults import m100_GS98
 
from pysep.io.nml.control.defaults import solar
from pysep.io.nml.physics.defaults import phys1Low
from pysep.io.nml.physics.defaults import phys1
 
 
import argparse
 
def load_surfBCFiles(five,six,seven,eight,nine):
    bcphx95 = bcphx95_file(five)
    bcphx96 = bcphx96_file(six)
    bcphx97 = bcphx97_file(seven)
    bcphx98 = bcphx98_file(eight)
    bcphx99 = bcphx99_file(nine)
    payload = {
            'bcphx95': bcphx95,
            'bcphx96': bcphx96,
            'bcphx97': bcphx97,
            'bcphx98': bcphx98,
            'bcphx99': bcphx99,
            }
    return payload
 
 
if __name__ == "__main__":
    parser = argparse.ArgumentParser(description="Test DSEP with different "
                                     "atmospheric boundary conditions quickly")
    parser.add_argument("--five", help="Path to bcphx95 table", type=str)
    parser.add_argument("--six", help="Path to bcphx96 table", type=str)
    parser.add_argument("--seven", help="Path to bcphx97 table", type=str)
    parser.add_argument("--eight", help="Path to bcphx98 table", type=str)
    parser.add_argument("--nine", help="Path to bcphx99 table", type=str)
 
    args = parser.parse_args()
    surfBCFiles = load_surfBCFiles(args.five, args.six, args.seven, args.eight, args.nine)
    model = sm("./modelOutput", solar, phys1, GS98hz, m100_GS98, **surfBCFiles)
    model.evolve()
    model.stash(data=True)