camber.mesa

Last updated:

Camber has a built-in engine to run workloads for MESA, a software suite to run experiments in stellar evolution.

import camber.mesa

Example

In this example, use the MESA engine to evolve a single star and plot the result on an HR diagram.

import camber.mesa
import matplotlib.pyplot as plt
import mesa_reader as mr

# Start a MESA job using the inlist file in the current directory.
# The default command "./mk && ./rn" compiles and runs the star module.
job = camber.mesa.create_job(command="./mk && ./rn")

# Check the job status
job.status

# Once job.status is RUNNING or COMPLETED, plot the HR diagram:
fig = plt.figure(figsize=(4, 6))

h = mr.MesaData('LOGS/history.data')
plt.plot(h.log_Teff, h.log_L, linewidth=0.75, zorder=1,
         label=str(round(h.star_mass[0], 4)) + r' $M_{\odot}$', color='black')
plt.annotate(str(round(h.star_mass[0], 4)) + r' $M_{\odot}$',
             (max(h.log_Teff) + 0.15, h.log_L[0]), fontsize=16)

plt.xlim(4.0, 3.5)
plt.ylim(-0.5, 4.5)
plt.grid(alpha=0.25)
plt.xlabel(r'$\log$(Teff)')
plt.ylabel(r'$\log$(L)')
plt.show()

print(max(h.star_age) / 1.0e9)

Methods

create_job

Executes a MESA job on CamberCloud.

Arguments

command: str
The command to execute the MESA job.
Default is ./mk && ./rn
module: str
The module to run simulations (such as star, binary, astero, and so on).
Default is star
sync_mesa_scripts: bool
Whether to sync MESA scripts to the job directory.
Default is True
node_size: str
The size of the node. One of XMICRO, MICRO, XXSMALL, XSMALL, SMALL, MEDIUM, or LARGE.
Default is XSMALL.
mount_dir: Optional[str]
The directory to mount as the working directory for the job.
Defaults to the current working directory.
extra_env_vars: Optional[Dict[str, str]]
Extra environment variables to pass to the MESA job
mesa_version: Optional[str]
The MESA version to use.
Default is r23.05.1
tags: Optional[Union[str, List]]
Tags to add to the job.
e.g. ["tag1", "tag2"] or "tag1".

Returns

CamberJob
The CamberJob object representing the created job.