Example of Stellar Model Opacity Configuration in PySEP
This Python script showcases a process to configure and run parallel stellar models leveraging opacity files in the PySEP library. It includes preparing the environment by organizing opacity files from different sources ('Ferg' and 'Aeso'), establishing model configurations, and finally executing these models in parallel. The script also highlights the use of conditional directory creation for outputs and updating model parameters with specific opacity file paths.
from pysep.api.starting import get_basic_stellar_model from pysep.dm.filetypes import opacf_file from pysep.api.parallel import pStellarModel import os FergLowTempRoot = "./inputs/opac/low/ferg04" AesoLowTempRoot1 = "./inputs/opac/low/aesopusExtend" AesoLowTempRoot2 = "./inputs/opac/low/aesopus" FergFiles = filter(lambda x: x.endswith(".tron"), os.listdir(FergLowTempRoot)) AesoFiles1 = filter(lambda x: x.endswith(".tron"), os.listdir(AesoLowTempRoot1)) AesoFiles2 = filter(lambda x: x.endswith(".tron"), os.listdir(AesoLowTempRoot2)) FergPaths = [os.path.abspath(os.path.join(FergLowTempRoot, x)) for x in FergFiles] AesoPaths1 = [os.path.abspath(os.path.join(AesoLowTempRoot1, x)) for x in AesoFiles1] AesoPaths2 = [os.path.abspath(os.path.join(AesoLowTempRoot2, x)) for x in AesoFiles2] if not os.path.exists("./fergOutput"): os.mkdir("./fergOutput") if not os.path.exists("./aesopusExtendOutput"): os.mkdir("./aesopusExtendOutput") if not os.path.exists("./aesopusOutput"): os.mkdir("./aesopusOutput") FergModel = get_basic_stellar_model("./fergOutput") AesoModel1 = get_basic_stellar_model("./aesopusExtendOutput") AesoModel2 = get_basic_stellar_model("./aesopusOutput") FergModel.control.update_low_temp_opacity_files(FergPaths) AesoModel1.control.update_low_temp_opacity_files(AesoPaths1) AesoModel2.control.update_low_temp_opacity_files(AesoPaths2) pModels = pStellarModel([FergModel, AesoModel1, AesoModel2], name="NewLowTempOpacTest") pModels.pEvolve(autoStash=True)