kaitiaki.STARSController ======================== .. py:module:: kaitiaki.STARSController Exceptions ---------- .. autoapisummary:: kaitiaki.STARSController.ServerError Classes ------- .. autoapisummary:: kaitiaki.STARSController.STARSController Functions --------- .. autoapisummary:: kaitiaki.STARSController.install kaitiaki.STARSController.recompile kaitiaki.STARSController._allocate_cores kaitiaki.STARSController._worker_evolve Module Contents --------------- .. py:exception:: ServerError(server_code, message) Bases: :py:obj:`Exception` Represents an error from the server Syntactic sugar for a server error. .. py:attribute:: server_code .. py:attribute:: message .. py:function:: install(install_path) Installs STARS Downloads the latest version of AotearoaSTARS from GitHub. :param install_path: The location to install AotearoaSTARS to. :type install_path: str :raises FileNotFoundError: If the repository could not be found :raises ServerError: If the HTTP response code is not 200 .. py:function:: recompile(install_path) Recompiles the STARS code Recompiles the STARS code. Executes make clean && make to do so. :param install_path: The location that the STARS code is installed to :type install_path: str :returns: a 2-tuple of 3-tuples representing ((stdout, stderr, termination_reason), (stdout, stderr, termination_reason)) for (make clean, make) respectively. :rtype: tuple :raises ChildProcessError: If either command fails. .. py:function:: _allocate_cores(reserve_core: bool) .. py:function:: _worker_evolve(directory, timeout, mass, do_he_flash, run_bs, STARS) .. py:class:: STARSController(verbose_output: bool = True, run_bs: str = '.') Represents an instance of the STARS code. .. py:attribute:: _verbose_output :value: True .. py:attribute:: _output_dir :value: '.' .. py:attribute:: _params .. py:attribute:: _run_bs_location :value: '.' .. py:attribute:: _datafile :value: 'data' .. py:attribute:: _options :value: None .. py:attribute:: _lexicon :value: None .. py:method:: blit(ZS='z020', directory='.') Blits the directory given by creating the COTables and data file. Loads the default data file and the default COtable. :param ZS: the metallicity (BPASS-formatted) to load opacity tables for. :param directory: The directory to blit. :returns: None .. rubric:: Notes - Also sets the parameters ZS and CH in the data file. CH is set to 0.75-2.5*ZS. - Creates a new file *data* in the directory specified. - Creates a new file *COtables* in the directory specified .. py:method:: set_period(period, directory='.', boost_max_nmodels=True, forcibly_do_both=False) Sets the period in the modin file. .. py:method:: use_lexicon(lexicon) .. py:method:: update_datafile(new_location) .. py:method:: update_run_bs(loc) .. py:method:: fetch_datafile() .. py:method:: load_default_modin(directory='.', as_secondary=False, Z='z020', set_nmodels_to=99999) .. py:method:: generate_datafile(loc) .. py:method:: output(msgtype, message) Outputs a message to stdout, if verbose_output is on. Does nothing otherwise. :param msgtype: The message type (warning, error, info, status) to output :type msgtype: str :param message: The message to output :type message: str .. py:method:: configure_parameters(params) Sets up the parameters. Doesn't commit them yet. :param params {dict} -- A dictionary containing key: value pairs :param of what to write to the datafile.: .. py:method:: _write_orbital_equations(block, dfile_name='') .. py:method:: setup_binary_evolution(dfile='data') Modifies data to allow for binary evolution. Sets the following :param ID block for binaries: :param IMODE - To 2: :type IMODE - To 2: binaries :param IML1 - To 5: Check what prescription is :type IML1 - To 5: custom :param IML2 - To 5: :type IML2 - To 5: custom :param RML - 0: :type RML - 0: off :param ITH - 1: :type ITH - 1: on :param IX - 1: :type IX - 1: on :param IY - 1: :type IY - 1: on :param IZ - 1: :type IZ - 1: on :param ISTART - 1: :type ISTART - 1: reset age, nmod, dt .. py:method:: setup_single_evolution(dfile='data') Modifies data to allow for single star evolution. Sets the following :param ID block for single stars: :param IMODE - To 1: :type IMODE - To 1: single stars :param IML1 - To 5: Check what prescription is :type IML1 - To 5: custom :param IML2 - To 0: :type IML2 - To 0: off - shouldn't matter though :param RML - 0: :type RML - 0: off :param ITH - 1: :type ITH - 1: on :param IX - 1: :type IX - 1: on :param IY - 1: :type IY - 1: on :param IZ - 1: :type IZ - 1: on :param ISTART - 1: :type ISTART - 1: reset age, nmod, dt .. py:method:: setup_zams_inflation(mass) Sets up the data and modin files for ZAMS inflation. :param mass {float} -- the ZAMS mass to set.: .. rubric:: Notes This *does not* actually inflate the star -- you still must call STARS.run() after this. .. py:method:: setup_evolution(mode='single', iml_option=5) .. py:method:: relax_model() .. py:method:: set_output_directory(directory) Sets up the output directory. If the directory doesn't exist, this will create it. :param directory {string} -- The directory to output files to.: .. py:method:: terminal_command(command, timeout=5 * 60, cwd=None, warn=True) Included for backwards compatibility. You should use kaitiaki.terminal.execute() instead .. py:method:: commit_parameters() .. py:method:: run(timeout=5 * 60, cwd=None, warn=True, time_me=False) Runs ./run_bs :returns: tuple -- The output from run() above. .. py:method:: get_last_converged_model(file, as_obj=False) .. py:method:: get_outfile_models(file: str) .. py:method:: evolve_async(masses, timeout: int = 20 * 60, evolution_dir: str = '', attempt_he_flash: bool = True, data_params: dict = dict(), reserve_core: bool = True, logged_masses: bool = False, ZAMS_files_location: str = '', metallicity: str = 'z020') .. py:method:: evolve_through_helium_flash(timeout=30 * 60, filedir='.') .. py:method:: modout_to_modin(modout_location='modout', modin_location='modin', n_models_ago=0) Moves the last model in modout to modin Reads modout to determine the number of lines to move (columns 88-94 of the first line). :param modout_location: The modout file to load (default: `"modout"`) :type modout_location: str :param modin_location: The modin file to write to (default: `"modin"`) :type modin_location: str :param n_models_ago: How many models ago to load (e.g. n_models_ago=3 loads 3 models back, n_models_ago=-1 loads the first model in the file, n_models_ago=0 loads the last model in the file.) (default: `0`) :type n_models_ago: number .. py:method:: run_default_evolution(zams_mass, NM2=199) Performs one run from pre-ZAMS until the end of evolution. Assumes NORMAL file structure. Not really useful for scientific applications -- just here for educational purposes on how STARS runs. :param zams_mass {float} -- The ZAMS mass we should target.: