MUSICA C++ API#

namespace musica#

Typedefs

using CudaSolverPtr = std::unique_ptr<IMicmSolver, CudaSolverDeleter>#

Unique pointer type for CUDA solvers with custom deleter.

using SolverResultStats = micm::SolverStats#
using SolverPtr = std::unique_ptr<IMicmSolver, std::function<void(IMicmSolver*)>>#

Type-erased solver pointer that can hold both CPU and CUDA solvers with different deleters.

Enums

enum class ParticleShape#

Values:

enumerator SPHERE#
enumerator HEXAGON#
enumerator CYLINDER#
enum class ParticleSwellingAlgorithm#

Values:

enumerator NONE#
enumerator FITZGERALD#
enumerator GERBER#
enumerator WEIGHT_PERCENT_H2SO4#
enumerator PETTERS#
enum class ParticleSwellingComposition#

Values:

enumerator NONE#
enumerator AMMONIUM_SULFATE#
enumerator SEA_SALT#
enumerator URBAN#
enumerator RURAL#
enum class FallVelocityAlgorithm#

Values:

enumerator NONE#
enumerator STANDARD_SPHERICAL_ONLY#
enumerator STANDARD_SHAPE_SUPPORT#
enumerator HEYMSFIELD_2010#
enum class MieCalculationAlgorithm#

Values:

enumerator TOON_1981#
enumerator BOHREN_1983#
enumerator BOTET_1997#
enum class OpticsAlgorithm#

Values:

enumerator NONE#
enumerator FIXED#
enumerator MIXED_YU_2015#
enumerator SULFATE_YU_2015#
enumerator MIXED_H2O_YU_2015#
enumerator MIXED_CORE_SHELL#
enumerator MIXED_VOLUME#
enumerator MIXED_MAXWELL#
enumerator SULFATE#
enum class VaporizationAlgorithm#

Values:

enumerator NONE#
enumerator H2O_BUCK_1981#
enumerator H2O_MURPHY_2005#
enumerator H2O_GOFF_1946#
enumerator H2SO4_AYERS_1980#
enum class ParticleType#

Values:

enumerator INVOLATILE#
enumerator VOLATILE#
enumerator COREMASS#
enumerator VOLCORE#
enumerator CORE2MOM#
enum GasComposition#

Values:

enumerator OTHER#
enumerator H2O#
enumerator H2SO4#
enumerator SO2#
enum class ParticleComposition#

Values:

enumerator ALUMINUM#
enumerator H2SO4#
enumerator DUST#
enumerator ICE#
enumerator H2O#
enumerator BLACKCARBON#
enumerator ORGANICCARBON#
enumerator OTHER#
enum class ParticleCollectionAlgorithm#

Values:

enumerator NONE#
enumerator CONSTANT#
enumerator FUCHS#
enumerator DATA#
enum class ParticleNucleationAlgorithm#

Values:

enumerator NONE#
enumerator AEROSOL_FREEZING_TABAZDEH_2000#
enumerator AEROSOL_FREEZING_KOOP_2000#
enumerator AEROSOL_FREEZING_MURRAY_2010#
enumerator DROPLET_ACTIVATION#
enumerator AEROSOL_FREEZING#
enumerator DROPLET_FREEZING#
enumerator ICE_MELTING#
enumerator HETEROGENEOUS_NUCLEATION#
enumerator HOMOGENEOUS_NUCLEATION#
enumerator HETEROGENEOUS_SULFURIC_ACID_NUCLEATION#
enum class SulfateNucleationMethod#

Values:

enumerator NONE#
enumerator ZHAO_TURCO#
enumerator VEHKAMAKI#
enum class CarmaCoordinates#

Values:

enumerator CARTESIAN#
enumerator SIGMA#
enumerator LONGITUDE_LATITUDE#
enumerator LAMBERT_CONFORMAL#
enumerator POLAR_STEREOGRAPHIC#
enumerator MERCATOR#
enumerator HYBRID#
enum MICMSolver#

Types of MICM solver.

Values:

enumerator UndefinedSolver#
enumerator Rosenbrock#
enumerator RosenbrockStandardOrder#
enumerator BackwardEuler#
enumerator BackwardEulerStandardOrder#
enumerator CudaRosenbrock#

Functions

char *GetCarmaVersion()#
void InternalGetCarmaVersion(char **version_ptr, int *version_length)#
void InternalFreeCarmaVersion(char *version_ptr, int version_length)#
void *InternalCreateCarma(const CCARMAParameters &params, int *rc)#
void InternalDestroyCarma(void *carma_instance, int *rc)#
void *InternalCreateCarmaState(void *carma_instance, const CCARMAParameters &carma_params, const CARMAStateParametersC &state_params, int *rc)#
void InternalDestroyCarmaState(void *carma_state_instance, int *rc)#
void InternalSetBin(void *carma_state_instance, int bin_index, int element_index, const double *values, int values_size, double surface_mass, int *rc)#
void InternalSetDetrain(void *carma_state_instance, int bin_index, int element_index, const double *values, int values_size, int *rc)#
void InternalSetGas(void *carma_state_instance, int gas_index, const double *values, int values_size, const double *old_mmr, int old_mmr_size, const double *gas_saturation_wrt_ice, int gas_saturation_wrt_ice_size, const double *gas_saturation_wrt_liquid, int gas_saturation_wrt_liquid_size, int *rc)#
void InternalGetStepStatistics(void *carma_state_instance, int *max_number_of_substeps, double *max_number_of_retries, double *total_number_of_steps, int *total_number_of_substeps, double *total_number_of_retries, double *xc, double *yc, double *z_substeps, int nz, int *rc)#
void InternalGetBin(void *carma_state_instance, int bin_index, int element_index, int nz, double *mass_mixing_ratio, double *number_mixing_ratio, double *number_density, double *nucleation_rate, double *wet_particle_radius, double *wet_particle_density, double *dry_particle_density, double *particle_mass_on_surface, double *sedimentation_flux, double *fall_velocity, double *deposition_velocity, double *delta_particle_temperature, double *kappa, double *total_mass_mixing_ratio, int *rc)#
void InternalGetDetrain(void *carma_state_instance, int bin_index, int element_index, int nz, double *mass_mixing_ratio, double *number_mixing_ratio, double *number_density, double *wet_particle_radius, double *wet_particle_density, int *rc)#
void InternalGetGas(void *carma_state_instance, int gas_index, int nz, double *mass_mixing_ratio, double *gas_saturation_wrt_ice, double *gas_saturation_wrt_liquid, double *gas_vapor_pressure_wrt_ice, double *gas_vapor_pressure_wrt_liquid, double *weight_pct_aerosol_composition, int *rc)#
void InternalGetEnvironmentalValues(void *carma_state_instance, int nz, double *temperature, double *pressure, double *air_density, double *latent_heat, int *rc)#
void InternalSetTemperature(void *carma_state_instance, const double *temperature, int temperature_size, int *rc)#
void InternalSetAirDensity(void *carma_state_instance, const double *air_density, int air_density_size, int *rc)#
void InternalStepCarmaState(void *carma_state_instance, const CARMAStateStepConfigC step_config, int *rc)#
void InternalGetGroupProperties(void *carma_instance, int group_index, int nbin, int nwave, int nelem, double *bin_radius, double *bin_radius_lower_bound, double *bin_radius_upper_bound, double *bin_width, double *bin_mass, double *bin_width_mass, double *bin_volume, double *projected_area_ratio, double *radius_ratio, double *porosity_ratio, double *extinction_coefficient, double *single_scattering_albedo, double *asymmetry_factor, int *particle_number_element_for_group, int *number_of_core_mass_elements_for_group, int *element_index_of_core_mass_elements, int *last_prognostic_bin, double *numbers_of_monomers_per_bin, int *rc)#
void InternalGetElementProperties(void *carma_instance, int element_index, CARMAElementPropertiesC *element_properties, int *rc)#
bool IsCudaAvailable()#
void SetLambdaCallback(const std::string &label, std::function<double(const micm::Conditions&)> fn)#

Register a callable for label.

The function is called with the atmospheric conditions at solve time and must return the rate-constant value. Passing a new function for the same label replaces the previous one.

double InvokeLambdaCallback(const std::string &label, const micm::Conditions &conditions)#

Invoke the callable registered for label.

Returns 0.0 if no callable has been registered for label.

std::string ToString(MICMSolver solver_type)#
MICM *CreateMicm(const char *config_path, MICMSolver solver_type, Error *error)#

Create a MICM object by specifying solver type to use and providing a path to the configuration file.

Parameters:
  • config_path – Path to configuration file or directory containing configuration file

  • solver_type – Type of MICMSolver

  • error – Error struct to indicate success or failure

Returns:

Pointer to MICM object

MICM *CreateMicmFromChemistryMechanism(const Chemistry *chemistry, MICMSolver solver_type, Error *error)#

Create a MICM object by specifying the solver type and providing a Chemistry object.

Parameters:
  • chemistryChemistry object

  • solver_type – Type of MICMSolver

  • error – Error struct to indicate success or failure

Returns:

Pointer to MICM object

MICM *CreateMicmFromConfigString(const char *config_string, MICMSolver solver_type, Error *error)#

Create a MICM object from a JSON or YAML configuration string.

Parameters:
  • config_string – JSON or YAML configuration string

  • solver_type – Type of MICMSolver

  • error – Error struct to indicate success or failure

Returns:

Pointer to MICM object

void DeleteMicm(MICM *micm, Error *error)#

Deletes a MICM object.

Parameters:
  • micm – Pointer to MICM object

  • error – Error struct to indicate success or failure

void MicmSolve(MICM *micm, musica::State *state, double time_step, String *solver_state, SolverResultStats *solver_stats, Error *error)#

Solve the system.

Parameters:
  • micm – Pointer to MICM object

  • state – Pointer to state object

  • time_step – Time [s] to advance the state by

  • solver_stateState of the solver

  • solver_stats – Statistics of the solver

  • error – Error struct to indicate success or failure

void MicmVersion(String *micm_version)#

Get the MICM version.

Parameters:

micm_versionMICM version [output]

void GetSpeciesPropertyString(MICM *micm, const char *species_name, const char *property_name, String *species_property, Error *error)#

Get a property for a chemical species.

Parameters:
  • micm – Pointer to MICM object [input]

  • species_name – Name of the species [input]

  • property_name – Name of the property [input]

  • species_property – Value of the property [output]

  • error – Error struct to indicate success or failure [output]

double GetSpeciesPropertyDouble(MICM *micm, const char *species_name, const char *property_name, Error *error)#
int GetSpeciesPropertyInt(MICM *micm, const char *species_name, const char *property_name, Error *error)#
bool GetSpeciesPropertyBool(MICM *micm, const char *species_name, const char *property_name, Error *error)#
size_t GetMaximumNumberOfGridCells(MICM *micm)#

Get the maximum number of grid cells per state.

Parameters:

micm – Pointer to MICM object

Returns:

Maximum number of grid cells

bool _IsCudaAvailable(Error *error)#
std::size_t GetVectorSize(musica::MICMSolver)#

Get the MUSICA vector size.

Returns:

The MUSICA vector size

void SetRosenbrockSolverParameters(MICM *micm, const RosenbrockSolverParametersC *params, Error *error)#

Set Rosenbrock solver parameters.

Parameters:
void SetBackwardEulerSolverParameters(MICM *micm, const BackwardEulerSolverParametersC *params, Error *error)#

Set Backward Euler solver parameters.

Parameters:
void GetRosenbrockSolverParameters(MICM *micm, RosenbrockSolverParametersC *params, Error *error)#

Get Rosenbrock solver parameters.

Parameters:
void GetBackwardEulerSolverParameters(MICM *micm, BackwardEulerSolverParametersC *params, Error *error)#

Get Backward Euler solver parameters.

Parameters:
Chemistry ReadConfiguration(const std::string &config_path)#
Chemistry ReadConfigurationFromString(const std::string &json_or_yaml_string)#
Chemistry ParserV0(const mechanism_configuration::ParserResult<> &result)#
Chemistry ConvertV1Mechanism(const mechanism_configuration::v1::types::Mechanism &v1_mechanism)#
Chemistry ParserV1(const mechanism_configuration::ParserResult<> &result)#
mechanism_configuration::v1::types::Mechanism ConvertV0MechanismToV1(const std::string &config_path, bool convert_reaction_units = true)#
mechanism_configuration::v1::types::Mechanism ConvertV0MechanismToV1(const mechanism_configuration::v0::types::Mechanism &v0_mechanism, bool convert_reaction_units = true)#
bool IsBool(const std::string &value)#
bool IsInt(const std::string &value)#
bool IsFloatingPoint(const std::string &value)#
State *CreateMicmState(musica::MICM *micm, size_t number_of_grid_cells, Error *error)#

Create a state object by specifying micm solver object using the solver variant.

Parameters:
  • micm – Pointer to MICM object

  • number_of_grid_cells – Number of grid cells

  • error – Error struct to indicate success or failure

void DeleteState(State *state, Error *error)#

Deletes a state object.

Parameters:
  • state – Pointer to state object

  • error – Error struct to indicate success or failure

micm::Conditions *GetConditionsPointer(musica::State *state, size_t *array_size, Error *error)#

Get the pointer to the conditions struct.

Parameters:
  • state – Pointer to state object

  • array_size – Overall size of the array (output)

  • error – Error struct to indicate success or failure

double *GetOrderedConcentrationsPointer(musica::State *state, size_t *array_size, Error *error)#

Get the point to the vector of the concentrations for Fortran interface.

Parameters:
  • state – Pointer to state object

  • array_size – Overall size of the array (output)

  • error – Error struct to indicate success or failure

Returns:

Pointer to the vector

double *GetOrderedRateParametersPointer(musica::State *state, size_t *array_size, Error *error)#

Get the point to the vector of the rates for Fortran interface.

Parameters:
  • state – Pointer to state object

  • array_size – Overall size of the array (output)

  • error – Error struct to indicate success or failure

Returns:

Pointer to the vector

void GetSpeciesOrdering(musica::State *state, Mappings *species_ordering, Error *error)#

Get the ordering of species.

Parameters:
  • state – Pointer to state object [input]

  • species_ordering – Array of species’ name-index pairs [output]

  • error – Error struct to indicate success or failure [output]

void GetUserDefinedRateParametersOrdering(musica::State *state, Mappings *reaction_rates, Error *error)#

Get the ordering of user-defined reaction rates.

Parameters:
  • state – Pointer to state object [input]

  • reaction_rates – Array of reaction rate name-index pairs [output]

  • error – Error struct to indicate success or failure [output]

size_t GetNumberOfGridCells(musica::State *state, Error *error)#

Returns the number of grid cells in the solver state.

Parameters:
  • state – Pointer to state object

  • error – Error struct to indicate success or failure

Returns:

Number of grid cells

size_t GetNumberOfSpecies(musica::State *state, Error *error)#

Returns the number of species in the solver state.

Parameters:
  • state – Pointer to state object

  • error – Error struct to indicate success or failure

Returns:

Number of species

void GetConcentrationsStrides(musica::State *state, Error *error, size_t *grid_cell_stride, size_t *species_stride)#

Returns the stride across grid cells for the concentration matrix.

Parameters:
  • state – Pointer to state object

  • error – Error struct to indicate success or failure

  • grid_cell_stride – Pointer to the stride across grid cells

  • species_stride – Pointer to the stride across species

size_t GetNumberOfUserDefinedRateParameters(musica::State *state, Error *error)#

Returns the number of user-defined rate parameters.

Parameters:
  • state – Pointer to state object

  • error – Error struct to indicate success or failure

Returns:

Number of user-defined rate parameters

void GetUserDefinedRateParametersStrides(musica::State *state, Error *error, size_t *grid_cell_stride, size_t *user_defined_rate_parameter_stride)#

Returns the stride across grid cells for the user-defined rate parameter matrix.

Parameters:
  • state – Pointer to state object

  • error – Error struct to indicate success or failure

  • grid_cell_stride – Pointer to the stride across grid cells

  • user_defined_rate_parameter_stride – Pointer to the stride across user-defined rate parameters

Grid *CreateGrid(const char *grid_name, const char *units, std::size_t num_sections, Error *error)#

Creates a TUV-x grid instance.

Parameters:
  • grid_name – The name of the grid

  • units – The units of the grid

  • num_sections – The number of sections in the grid

  • error – The error struct to indicate success or failure

const char *GetGridName(Grid *grid, Error *error)#

Gets the name of the grid.

Parameters:
  • grid – The grid to get the name from

  • error – The error struct to indicate success or failure

Returns:

The name of the grid

const char *GetGridUnits(Grid *grid, Error *error)#

Gets the units of the grid.

Parameters:
  • grid – The grid to get the units from

  • error – The error struct to indicate success or failure

Returns:

The units of the grid

std::size_t GetGridNumberOfSections(Grid *grid, Error *error)#

Gets the number of sections in the grid.

Parameters:
  • grid – The grid to get the number of sections from

  • error – The error struct to indicate success or failure

Returns:

The number of sections in the grid

void DeleteGrid(Grid *grid, Error *error)#

Deletes a TUV-x grid instance.

Parameters:
  • grid – The grid to delete

  • error – The error struct to indicate success or failure

void SetGridEdges(Grid *grid, double edges[], std::size_t num_edges, Error *error)#

Sets the values of the edges of the grid.

Parameters:
  • grid – The grid to set the edges of

  • edges – The edge values to set for the grid

  • num_edges – The number of edges

  • error – The error struct to indicate success or failure

void GetGridEdges(Grid *grid, double edges[], std::size_t num_edges, Error *error)#

Gets the values of the edges of the grid.

Parameters:
  • grid – The grid to get the edges of

  • edges – The edge values to get for the grid

  • num_edges – The number of edges

  • error – The error struct to indicate success or failure

double *GetGridEdgesPointer(Grid *grid, Error *error)#

Return a pointer to the edges array of the grid.

Parameters:
  • grid – The grid to get the edges pointer from

  • error – The error struct to indicate success or failure

Returns:

A pointer to the edges array

void SetGridMidpoints(Grid *grid, double midpoints[], std::size_t num_midpoints, Error *error)#

Sets the values of the midpoints of the grid.

Parameters:
  • grid – The grid to set the midpoints of

  • midpoints – The midpoint values to set for the grid

  • num_midpoints – The number of midpoints

  • error – The error struct to indicate success or failure

void GetGridMidpoints(Grid *grid, double midpoints[], std::size_t num_midpoints, Error *error)#

Gets the values of the midpoints of the grid.

Parameters:
  • grid – The grid to get the midpoints of

  • midpoints – The midpoint values to get for the grid

  • num_midpoints – The number of midpoints

  • error – The error struct to indicate success or failure

double *GetGridMidpointsPointer(Grid *grid, Error *error)#

Return a pointer to the midpoints array of the grid.

Parameters:
  • grid – The grid to get the midpoints pointer from

  • error – The error struct to indicate success or failure

Returns:

A pointer to the midpoints array

void *InternalCreateGrid(const char *grid_name, std::size_t grid_name_length, const char *units, std::size_t units_length, std::size_t num_sections, int *error_code)#
void InternalDeleteGrid(void *grid, int *error_code)#
void *InternalGetGridUpdater(void *grid, int *error_code)#
void InternalDeleteGridUpdater(void *updater, int *error_code)#
void InternalGetGridName(void *grid, String *name, int *error_code)#
void InternalGetGridUnits(void *grid, String *units, int *error_code)#
std::size_t InternalGetNumberOfSections(void *grid, int *error_code)#
void InternalSetEdges(void *grid, double edges[], std::size_t num_edges, int *error_code)#
void InternalGetEdges(void *grid, double edges[], std::size_t num_edges, int *error_code)#
double *InternalGetEdgesPointer(void *grid, int *error_code)#
void InternalSetMidpoints(void *grid, double midpoints[], std::size_t num_midpoints, int *error_code)#
void InternalGetMidpoints(void *grid, double midpoints[], std::size_t num_midpoints, int *error_code)#
double *InternalGetMidpointsPointer(void *grid, int *error_code)#
GridMap *CreateGridMap(Error *error)#

Creates a grid map instance.

Parameters:

error – The error struct to indicate success or failure

Returns:

a pointer to the grid map

void DeleteGridMap(GridMap *grid_map, Error *error)#

Deletes a grid map instance.

Parameters:
  • grid_map – The grid map to delete

  • error – The error struct to indicate success or failure

void AddGrid(GridMap *grid_map, Grid *grid, Error *error)#

Adds a grid to the grid map.

Parameters:
  • grid_map – The grid map to add the grid to

  • grid – The grid to add

  • error – The error struct to indicate success or failure

Grid *GetGrid(GridMap *grid_map, const char *grid_name, const char *grid_units, Error *error)#

Returns a grid from the grid map.

Parameters:
  • grid_map – The grid map to get the grid from

  • grid_name – The name of the grid we want

  • grid_units – The units of the grid we want

  • error – The error struct to indicate success or failure

Returns:

The grid pointer, or nullptr if the grid is not found

Grid *GetGridByIndex(GridMap *grid_map, std::size_t index, Error *error)#

Returns a grid by index from the grid map.

Parameters:
  • grid_map – The grid map to get the grid from

  • index – The index of the grid we want

  • error – The error struct to indicate success or failure

Returns:

The grid pointer, or nullptr if the index is out of range

std::size_t GetNumberOfGrids(GridMap *grid_map, Error *error)#

Gets the number of grids in the map.

Parameters:
  • grid_map – The grid map to get the number of grids from

  • error – The error struct to indicate success or failure

Returns:

the number of grids in the map

void RemoveGrid(GridMap *grid_map, const char *grid_name, const char *grid_units, Error *error)#

Removes a grid from the map.

Parameters:
  • grid_map – The grid map to remove the grid from

  • grid_name – The name of the grid to remove

  • grid_units – The units of the grid to remove

  • error – The error struct to indicate success or failure

void RemoveGridByIndex(GridMap *grid_map, std::size_t index, Error *error)#

Removes a grid from the map by index.

Parameters:
  • grid_map – The grid map to remove the grid from

  • index – The index of the grid to remove

  • error – The error struct to indicate success or failure

void *InternalCreateGridMap(int *error_code)#
void InternalDeleteGridMap(void *grid_map, int *error_code)#
void InternalAddGrid(void *grid_map, void *grid, int *error_code)#
void *InternalGetGrid(void *grid_map, const char *grid_name, std::size_t grid_name_length, const char *grid_units, std::size_t grid_units_length, int *error_code)#
void *InternalGetGridUpdaterFromMap(void *grid_map, void *grid, int *error_code)#
std::size_t InternalGetNumberOfGrids(void *grid_map, int *error_code)#
void *InternalGetGridByIndex(void *grid_map, std::size_t index, int *error_code)#
void InternalRemoveGrid(void *grid_map, const char *grid_name, std::size_t grid_name_length, const char *grid_units, std::size_t grid_units_length, int *error_code)#
void InternalRemoveGridByIndex(void *grid_map, std::size_t index, int *error_code)#
Profile *CreateProfile(const char *profile_name, const char *units, Grid *grid, Error *error)#

Creates a new profile instance.

Parameters:
  • profile_name – The name of the profile

  • units – The units of the profile

  • grid – The grid to use for the profile

  • error – The error struct to indicate success or failure

void DeleteProfile(Profile *profile, Error *error)#

Deletes a profile instance.

Parameters:
  • profile – The profile to delete

  • error – The error struct to indicate success or failure

const char *GetProfileName(Profile *profile, Error *error)#

Gets the name of the profile.

Parameters:
  • profile – The profile to get the name of

  • error – The error struct to indicate success or failure

Returns:

The name of the profile

const char *GetProfileUnits(Profile *profile, Error *error)#

Gets the units of the profile.

Parameters:
  • profile – The profile to get the units of

  • error – The error struct to indicate success or failure

Returns:

The units of the profile

void SetProfileEdgeValues(Profile *profile, double edge_values[], std::size_t num_values, Error *error)#

Sets the values at edges of the profile grid.

Parameters:
  • profile – The profile to set the edge values of

  • edge_values – The edge values to set for the profile

  • num_values – The number of values

  • error – The error struct to indicate success or failure

void GetProfileEdgeValues(Profile *profile, double edge_values[], std::size_t num_values, Error *error)#

Gets the values at edges of the profile grid.

Parameters:
  • profile – The profile to get the edge values of

  • edge_values – The edge values to get for the profile

  • num_values – The number of values

  • error – The error struct to indicate success or failure

double *GetProfileEdgeValuesPointer(Profile *profile, Error *error)#

Returns a pointer to the edge values array.

Parameters:
  • profile – The profile to get the edge values pointer of

  • error – The error struct to indicate success or failure

Returns:

A pointer to the edge values array

void SetProfileMidpointValues(Profile *profile, double midpoint_values[], std::size_t num_values, Error *error)#

Sets the values at midpoints of the profile grid.

Parameters:
  • profile – The profile to set the midpoint values of

  • midpoint_values – The midpoint values to set for the profile

  • num_values – The number of values

  • error – The error struct to indicate success or failure

void GetProfileMidpointValues(Profile *profile, double midpoint_values[], std::size_t num_values, Error *error)#

Gets the values at midpoints of the profile grid.

Parameters:
  • profile – The profile to get the midpoint values of

  • midpoint_values – The midpoint values to get for the profile

  • num_values – The number of values

  • error – The error struct to indicate success or failure

double *GetProfileMidpointValuesPointer(Profile *profile, Error *error)#

Returns a pointer to the midpoint values array.

Parameters:
  • profile – The profile to get the midpoint values pointer of

  • error – The error struct to indicate success or failure

Returns:

A pointer to the midpoint values array

void SetProfileLayerDensities(Profile *profile, double layer_densities[], std::size_t num_values, Error *error)#

Sets the layer densities for each grid section of the profile.

Parameters:
  • profile – The profile to set the layer densities of

  • layer_densities – The layer densities to set for the profile

  • num_values – The number of values

  • error – The error struct to indicate success or failure

void GetProfileLayerDensities(Profile *profile, double layer_densities[], std::size_t num_values, Error *error)#

Gets the layer densities for each grid section of the profile.

Parameters:
  • profile – The profile to get the layer densities of

  • layer_densities – The layer densities to get for the profile

  • num_values – The number of values

  • error – The error struct to indicate success or failure

double *GetProfileLayerDensitiesPointer(Profile *profile, Error *error)#

Returns a pointer to the layer densities array.

Parameters:
  • profile – The profile to get the layer densities pointer of

  • error – The error struct to indicate success or failure

Returns:

A pointer to the layer densities array

void SetProfileExoLayerDensity(Profile *profile, double exo_layer_density, Error *error)#

Sets the layer density above the top of the profile grid.

Parameters:
  • profile – The profile to set the exo layer density of

  • exo_layer_density – The exo layer density to set for the profile

  • error – The error struct to indicate success or failure

void CalculateProfileExoLayerDensity(Profile *profile, double scale_height, Error *error)#

Calculates an exo layer density based on a provided scale height.

Parameters:
  • profile – The profile to calculate the exo layer density of

  • scale_height – The scale height to use in the calculation

  • error – The error struct to indicate success or failure

double GetProfileExoLayerDensity(Profile *profile, Error *error)#

Gets the density above the top of the profile grid.

Parameters:
  • profile – The profile to get the exo layer density of

  • error – The error struct to indicate success or failure

Returns:

The exo layer density

std::size_t GetProfileNumberOfSections(Profile *profile, Error *error)#

Returns the number of sections in the profile’s grid.

Parameters:
  • profile – The profile to get the number of sections of

  • error – The error struct to indicate success or failure

Returns:

The number of sections in the profile’s grid

void *InternalCreateProfile(const char *profile_name, std::size_t profile_name_length, const char *units, std::size_t units_length, void *grid, int *error_code)#
void InternalDeleteProfile(void *profile, int *error_code)#
void *InternalGetProfileUpdater(void *profile, int *error_code)#
void InternalDeleteProfileUpdater(void *updater, int *error_code)#
void InternalGetProfileName(void *profile, String *name, int *error_code)#
void InternalGetProfileUnits(void *profile, String *units, int *error_code)#
void InternalSetEdgeValues(void *profile, double edge_values[], std::size_t num_values, int *error_code)#
void InternalGetEdgeValues(void *profile, double edge_values[], std::size_t num_values, int *error_code)#
double *InternalGetEdgeValuesPointer(void *profile, int *error_code)#
void InternalSetMidpointValues(void *profile, double midpoint_values[], std::size_t num_values, int *error_code)#
void InternalGetMidpointValues(void *profile, double midpoint_values[], std::size_t num_values, int *error_code)#
double *InternalGetMidpointValuesPointer(void *profile, int *error_code)#
void InternalSetLayerDensities(void *profile, double layer_densities[], std::size_t num_values, int *error_code)#
void InternalGetLayerDensities(void *profile, double layer_densities[], std::size_t num_values, int *error_code)#
double *InternalGetLayerDensitiesPointer(void *profile, int *error_code)#
void InternalSetExoLayerDensity(void *profile, double exo_layer_density, int *error_code)#
void InternalCalculateExoLayerDensity(void *profile, double scale_height, int *error_code)#
double InternalGetExoLayerDensity(void *profile, int *error_code)#
std::size_t InternalProfileGetNumberOfSections(void *profile, int *error_code)#
ProfileMap *CreateProfileMap(Error *error)#

Creates a profile map instance.

Parameters:

error – The error struct to indicate success or failure

Returns:

a pointer to the profile map

void DeleteProfileMap(ProfileMap *profile_map, Error *error)#

Deletes a profile map instance.

Parameters:
  • profile_map – The profile map to delete

  • error – The error struct to indicate success or failure

void AddProfile(ProfileMap *profile_map, Profile *profile, Error *error)#

Adds a profile to the profile map.

Parameters:
  • profile_map – The profile map to add the profile to

  • profile – The profile to add

  • error – The error struct to indicate success or failure

Profile *GetProfile(ProfileMap *profile_map, const char *profile_name, const char *profile_units, Error *error)#

Returns a profile from the profile map.

Parameters:
  • profile_map – The profile map to get the profile from

  • profile_name – The name of the profile we want

  • profile_units – The units of the profile we want

  • error – The error struct to indicate success or failure

Returns:

a profile pointer, or nullptr if the profile is not found

Profile *GetProfileByIndex(ProfileMap *profile_map, std::size_t index, Error *error)#

Returns a profile by index in the map.

Parameters:
  • profile_map – The profile map to get the profile from

  • index – The index of the profile we want

  • error – The error struct to indicate success or failure

Returns:

a profile pointer, or nullptr if the index is out of range

void RemoveProfile(ProfileMap *profile_map, const char *profile_name, const char *profile_units, Error *error)#

Removes a profile from the map by name and units.

Parameters:
  • profile_map – The profile map to remove the profile from

  • profile_name – The name of the profile to remove

  • profile_units – The units of the profile to remove

  • error – The error struct to indicate success or failure

void RemoveProfileByIndex(ProfileMap *profile_map, std::size_t index, Error *error)#

Removes a profile from the map by index.

Parameters:
  • profile_map – The profile map to remove the profile from

  • index – The index of the profile to remove

  • error – The error struct to indicate success or failure

std::size_t GetNumberOfProfiles(ProfileMap *profile_map, Error *error)#

Gets the number of profiles in the map.

Parameters:
  • profile_map – The profile map to get the number of profiles from

  • error – The error struct to indicate success or failure

Returns:

The number of profiles in the map

void *InternalCreateProfileMap(int *error_code)#
void InternalDeleteProfileMap(void *profile_map, int *error_code)#
void InternalAddProfile(void *profile_map, void *profile, int *error_code)#
void *InternalGetProfile(void *profile_map, const char *profile_name, std::size_t profile_name_length, const char *profile_units, std::size_t profile_units_length, int *error_code)#
void *InternalGetProfileByIndex(void *profile_map, std::size_t index, int *error_code)#
void *InternalGetProfileUpdaterFromMap(void *profile_map, void *profile, int *error_code)#
void InternalRemoveProfile(void *profile_map, const char *profile_name, std::size_t profile_name_length, const char *profile_units, std::size_t profile_units_length, int *error_code)#
void InternalRemoveProfileByIndex(void *profile_map, std::size_t index, int *error_code)#
std::size_t InternalGetNumberOfProfiles(void *profile_map, int *error_code)#
Radiator *CreateRadiator(const char *radiator_name, Grid *height_grid, Grid *wavelength_grid, Error *error)#

Creates radiator.

Parameters:
  • radiator_nameRadiator name

  • height_grid – Height grid

  • wavelength_grid – Wavelength grid

  • error – Error to indicate success or failure

void DeleteRadiator(Radiator *radiator, Error *error)#

Deletes radiator.

Parameters:
  • radiatorRadiator

  • error – Error to indicate success or failure

const char *GetRadiatorName(Radiator *radiator, Error *error)#

Gets the name of the radiator.

Parameters:
  • radiatorRadiator

  • error – Error to indicate success or failure

Returns:

The name of the radiator

void SetRadiatorOpticalDepths(Radiator *radiator, double *optical_depths, std::size_t num_vertical_layers, std::size_t num_wavelength_bins, Error *error)#

Sets optical depth values.

Parameters:
  • radiatorRadiator

  • optical_depths – 2D array of optical depth values

  • num_vertical_layers – Number of vertical layers

  • num_wavelength_bins – Number of wavelength bins

  • error – Error to indicate success or failure

void GetRadiatorOpticalDepths(Radiator *radiator, double *optical_depths, std::size_t num_vertical_layers, std::size_t num_wavelength_bins, Error *error)#

Gets optical depth values.

Parameters:
  • radiatorRadiator

  • optical_depths – 2D array of optical depth values

  • num_vertical_layers – Number of vertical layers

  • num_wavelength_bins – Number of wavelength bins

  • error – Error to indicate success or failure

double *GetRadiatorOpticalDepthsPointer(Radiator *radiator, Error *error)#

Returns a pointer to the optical depths array.

Parameters:
  • radiatorRadiator

  • error – Error to indicate success or failure

Returns:

A pointer to the optical depths array

void SetRadiatorSingleScatteringAlbedos(Radiator *radiator, double *single_scattering_albedos, std::size_t num_vertical_layers, std::size_t num_wavelength_bins, Error *error)#

Sets single scattering albedos values.

Parameters:
  • radiatorRadiator

  • single_scattering_albedos – 2D array of single scattering albedos values

  • num_vertical_layers – Number of vertical layers

  • num_wavelength_bins – Number of wavelength bins

  • error – Error to indicate success or failure

void GetRadiatorSingleScatteringAlbedos(Radiator *radiator, double *single_scattering_albedos, std::size_t num_vertical_layers, std::size_t num_wavelength_bins, Error *error)#

Gets single scattering albedos values.

Parameters:
  • radiatorRadiator

  • single_scattering_albedos – 2D array of single scattering albedos values

  • num_vertical_layers – Number of vertical layers

  • num_wavelength_bins – Number of wavelength bins

  • error – Error to indicate success or failure

double *GetRadiatorSingleScatteringAlbedosPointer(Radiator *radiator, Error *error)#

Return a pointer to the single scattering albedos array.

Parameters:
  • radiatorRadiator

  • error – Error to indicate success or failure

Returns:

A pointer to the single scattering albedos array

void SetRadiatorAsymmetryFactors(Radiator *radiator, double *asymmetry_factor, std::size_t num_vertical_layers, std::size_t num_wavelength_bins, std::size_t num_streams, Error *error)#

Sets asymmetry factor values.

Parameters:
  • radiatorRadiator

  • asymmetry_factor – 3D array of asymmetery factor values

  • num_vertical_layers – Number of vertical layers

  • num_wavelength_bins – Number of wavelength bins

  • num_streams – Number of streams

  • error – Error to indicate success or failure

void GetRadiatorAsymmetryFactors(Radiator *radiator, double *asymmetry_factor, std::size_t num_vertical_layers, std::size_t num_wavelength_bins, std::size_t num_streams, Error *error)#

Gets asymmetry factor values.

Parameters:
  • radiatorRadiator

  • asymmetry_factor – 3D array of asymmetery factor values

  • num_vertical_layers – Number of vertical layers

  • num_wavelength_bins – Number of wavelength bins

  • num_streams – Number of streams

  • error – Error to indicate success or failure

double *GetRadiatorAsymmetryFactorsPointer(Radiator *radiator, Error *error)#

Return a pointer to the asymmetry factors array.

Parameters:
  • radiatorRadiator

  • error – Error to indicate success or failure

Returns:

A pointer to the asymmetry factors array

std::size_t GetRadiatorNumberOfHeightSections(Radiator *radiator, Error *error)#

Return the number of sections in the radiator’s height grid.

Parameters:
  • radiatorRadiator

  • error – The error struct to indicate success or failure

Returns:

The number of sections in the radiator’s height grid

std::size_t GetRadiatorNumberOfWavelengthSections(Radiator *radiator, Error *error)#

Return the number of sections in the radiator’s wavelength grid.

Parameters:
  • radiatorRadiator

  • error – The error struct to indicate success or failure

Returns:

The number of sections in the radiator’s wavelength grid

void *InternalCreateRadiator(const char *radiator_name, std::size_t radiator_name_length, void *height_grid, void *wavelength_grid, int *error_code)#
void InternalDeleteRadiator(void *radiator, int *error_code)#
void *InternalGetRadiatorUpdater(void *radiator, int *error_code)#
void InternalDeleteRadiatorUpdater(void *updater, int *error_code)#
void InternalGetRadiatorName(void *radiator, String *str, int *error_code)#
void InternalSetOpticalDepths(void *radiator, double *optical_depths, std::size_t num_vertical_layers, std::size_t num_wavelength_bins, int *error_code)#
void InternalGetOpticalDepths(void *radiator, double *optical_depths, std::size_t num_vertical_layers, std::size_t num_wavelength_bins, int *error_code)#
double *InternalGetOpticalDepthsPointer(void *radiator, int *error_code)#
void InternalSetSingleScatteringAlbedos(void *radiator, double *single_scattering_albedos, std::size_t num_vertical_layers, std::size_t num_wavelength_bins, int *error_code)#
void InternalGetSingleScatteringAlbedos(void *radiator, double *single_scattering_albedos, std::size_t num_vertical_layers, std::size_t num_wavelength_bins, int *error_code)#
double *InternalGetSingleScatteringAlbedosPointer(void *radiator, int *error_code)#
void InternalSetAsymmetryFactors(void *radiator, double *asymmetry_factors, std::size_t num_vertical_layers, std::size_t num_wavelength_bins, std::size_t num_streams, int *error_code)#
void InternalGetAsymmetryFactors(void *radiator, double *asymmetry_factors, std::size_t num_vertical_layers, std::size_t num_wavelength_bins, std::size_t num_streams, int *error_code)#
double *InternalGetAsymmetryFactorsPointer(void *radiator, int *error_code)#
std::size_t InternalGetRadiatorNumberOfHeightSections(void *radiator, int *error_code)#
std::size_t InternalGetRadiatorNumberOfWavelengthSections(void *radiator, int *error_code)#
RadiatorMap *CreateRadiatorMap(Error *error)#

Creates radiator map.

Parameters:

error – Error to indicate success or failure

Returns:

Radiator map

void DeleteRadiatorMap(RadiatorMap *radiator_map, Error *error)#

Deletes radiator map.

Parameters:
  • radiator_mapRadiator map to delete

  • error – Error to indicate success or failure

void AddRadiator(RadiatorMap *radiator_map, Radiator *radiator, Error *error)#

Adds a radiator to the radiator map.

Parameters:
  • radiator_mapRadiator map to add the radiator to

  • radiatorRadiator to add

  • error – Error to indicate success or failure

Radiator *GetRadiator(RadiatorMap *radiator_map, const char *radiator_name, Error *error)#

Returns a radiator from the radiator map.

Parameters:
  • radiator_mapRadiator map to get the radiator from

  • radiator_nameRadiator name

  • error – Error to indicate success or failure

Returns:

The radiator pointer, or nullptr if the radiator is not found

Radiator *GetRadiatorByIndex(RadiatorMap *radiator_map, std::size_t index, Error *error)#

Returns a radiator from the radiator map by index.

Parameters:
  • radiator_mapRadiator map to get the radiator from

  • index – Index of the radiator we want

  • error – Error to indicate success or failure

Returns:

The radiator pointer, or nullptr if the radiator is not found

void RemoveRadiator(RadiatorMap *radiator_map, const char *radiator_name, Error *error)#

Removes a radiator from the radiator map by name.

Parameters:
  • radiator_mapRadiator map to remove the radiator from

  • radiator_nameRadiator name

  • error – Error to indicate success or failure

void RemoveRadiatorByIndex(RadiatorMap *radiator_map, std::size_t index, Error *error)#

Removes a radiator from the radiator map by index.

Parameters:
  • radiator_mapRadiator map to remove the radiator from

  • index – Index of the radiator to remove

  • error – Error to indicate success or failure

std::size_t GetNumberOfRadiators(RadiatorMap *radiator_map, Error *error)#

Gets the number of radiators in the radiator map.

Parameters:
  • radiator_mapRadiator map to get the number of radiators from

  • error – Error to indicate success or failure

Returns:

Number of radiators in the radiator map

void *InternalCreateRadiatorMap(int *error_code)#
void InternalDeleteRadiatorMap(void *radiator_map, int *error_code)#
void InternalAddRadiator(void *radiator_map, void *radiator, int *error_code)#
void *InternalGetRadiator(void *radiator_map, const char *radiator_name, std::size_t radiator_name_length, int *error_code)#
void *InternalGetRadiatorByIndex(void *radiator_map, std::size_t index, int *error_code)#
void *InternalGetRadiatorUpdaterFromMap(void *radiator_map, void *radiator, int *error_code)#
void InternalRemoveRadiator(void *radiator_map, const char *radiator_name, std::size_t radiator_name_length, int *error_code)#
void InternalRemoveRadiatorByIndex(void *radiator_map, std::size_t index, int *error_code)#
std::size_t InternalGetNumberOfRadiators(void *radiator_map, int *error_code)#
TUVX *CreateTuvx(const char *config_path, GridMap *grids, ProfileMap *profiles, RadiatorMap *radiators, Error *error)#

Creates a TUVX instance by passing a configuration file path and host-defined grids, profiles, and radiators.

Parameters:
  • config_path – Path to configuration file

  • gridsGrid map from host application

  • profilesProfile map from host application

  • radiatorsRadiator map from host application

  • error – Error struct to indicate success or failure

TUVX *CreateTuvxFromConfigString(const char *config_string, GridMap *grids, ProfileMap *profiles, RadiatorMap *radiators, Error *error)#

Creates a TUVX instance by passing a configuration string and host-defined grids, profiles, and radiators.

Parameters:
  • config_string – JSON/YAML configuration string

  • gridsGrid map from host application

  • profilesProfile map from host application

  • radiatorsRadiator map from host application

  • error – Error struct to indicate success or failure

void DeleteTuvx(const TUVX *tuvx, Error *error)#

Deletes a TUVX instance.

Parameters:
  • tuvx – Pointer to TUVX instance

  • error – Error struct to indicate success or failure

GridMap *GetGridMap(TUVX *tuvx, Error *error)#

Returns the set of grids used by TUVX.

Parameters:
  • tuvx – Pointer to TUVX instance

  • error – Error struct to indicate success or failure

Returns:

Grid map

ProfileMap *GetProfileMap(TUVX *tuvx, Error *error)#

Returns the set of profiles used by TUVX.

Parameters:
  • tuvx – Pointer to TUVX instance

  • error – Error struct to indicate success or failure

Returns:

Profile map

RadiatorMap *GetRadiatorMap(TUVX *tuvx, Error *error)#

Returns the set of radiators used by TUVX.

Parameters:
  • tuvx – Pointer to TUVX instance

  • error – Error struct to indicate success or failure

Returns:

Radiator map

void GetPhotolysisRateConstantsOrdering(TUVX *tuvx, Mappings *mappings, Error *error)#

Returns the ordering photolysis rate constants.

Parameters:
  • tuvx – Pointer to TUVX instance

  • mappings – Array of photolysis rate constant name-index pairs [output]

  • error – Error struct to indicate success or failure

void GetHeatingRatesOrdering(TUVX *tuvx, Mappings *mappings, Error *error)#

Returns the ordering of heating rates.

Parameters:
  • tuvx – Pointer to TUVX instance

  • mappings – Array of heating rate name-index pairs [output]

  • error – Error struct to indicate success or failure

void GetDoseRatesOrdering(TUVX *tuvx, Mappings *mappings, Error *error)#

Returns the ordering of dose rates.

Parameters:
  • tuvx – Pointer to TUVX instance

  • mappings – Array of dose rate name-index pairs [output]

  • error – Error struct to indicate success or failure

void RunTuvx(TUVX *tuvx, const double solar_zenith_angle, const double earth_sun_distance, double *const photolysis_rate_constants, double *const heating_rates, double *const dose_rates, double *const actinic_flux, double *const spectral_irradiance, Error *const error)#

Run the TUV-x photolysis calculator.

Parameters:
  • tuvx – Pointer to TUVX instance

  • solar_zenith_angle – Solar zenith angle [radians]

  • earth_sun_distance – Earth-Sun distance [AU]

  • photolysis_rate_constants – Photolysis rate constant [s^-1] (reaction, vertical edge)

  • heating_rates – Heating rates [K/s] (heating_reaction, vertical edge)

  • dose_rates – Dose rates [W/m^2] (dose_rate type, vertical edge)

  • actinic_flux – Actinic flux [photons cm^-2 s^-1 nm^-1] (wavelength, vertical edge, direct/upwelling/downwelling)

  • spectral_irradiance – Spectral irradiance [W m^-2 nm^-1] (wavelength, vertical edge, direct/upwelling/downwelling)

  • error – Error struct to indicate success or failure

void TuvxVersion(String *tuvx_version)#

Get the TUVX version.

Parameters:

tuvx_versionTUVX version [output]

void *InternalCreateTuvx(const char *config_path, std::size_t config_path_length, void *grid_map, void *profile_map, void *radiator_map, int *number_of_height_midpoints, int *number_of_wavelength_midpoints, int *error_code)#
void *InternalCreateTuvxFromConfigString(const char *config_string, std::size_t config_string_length, void *grid_map, void *profile_map, void *radiator_map, int *number_of_height_midpoints, int *number_of_wavelength_midpoints, int *error_code)#
void InternalDeleteTuvx(void *tuvx, int *error_code)#
void *InternalGetGridMap(void *tuvx, int *error_code)#
void *InternalGetProfileMap(void *tuvx, int *error_code)#
void *InternalGetRadiatorMap(void *tuvx, int *error_code)#
void InternalGetPhotolysisRateConstantsOrdering(void *tuvx, Mappings *mappings, int *error_code)#
void InternalGetHeatingRatesOrdering(void *tuvx, Mappings *mappings, int *error_code)#
void InternalGetDoseRatesOrdering(void *tuvx, Mappings *mappings, int *error_code)#
void InternalRunTuvx(void *tuvx, const int number_of_height_midpoints, const int number_of_wavelength_midpoints, const double solar_zenith_angle, const double earth_sun_distance, double *photolysis_rate_constants, double *heating_rates, double *dose_rates, double *actinic_flux, double *spectral_irradiance, int *error_code)#
void InternalGetTuvxVersion(char **version_ptr, int *version_length)#
void InternalFreeTuvxVersion(char *version_ptr, int version_length)#
int InternalGetPhotolysisRateConstantCount(void *tuvx, int *error_code)#
int InternalGetHeatingRateCount(void *tuvx, int *error_code)#
int InternalGetDoseRateCount(void *tuvx, int *error_code)#
int InternalGetNumberOfHeightMidpoints(void *tuvx, int *error_code)#
int InternalGetNumberOfWavelengthMidpoints(void *tuvx, int *error_code)#
std::string strip_name(const std::string &name)#
double convert_molecules_cm3_to_moles_m3(std::vector<mechanism_configuration::v1::types::ReactionComponent> reactants, double molecules_cm3)#
double k0_A_convert_molecules_cm3_to_moles_m3(std::vector<mechanism_configuration::v1::types::ReactionComponent> reactants, double molecules_cm3)#
std::vector<mechanism_configuration::v1::types::Species> convert_species_v0_to_v1(const std::vector<mechanism_configuration::v0::types::Species> &v0_species)#
mechanism_configuration::v1::types::Reactions convert_reactions_v0_to_v1(const mechanism_configuration::v0::types::Reactions &v0_reactions, bool convert_reaction_units)#
std::vector<mechanism_configuration::v1::types::ReactionComponent> convert_reaction_components_v0_to_v1(const std::vector<mechanism_configuration::v0::types::ReactionComponent> &v0_components)#
mechanism_configuration::v1::types::ReactionComponent convert_reaction_component_v0_to_v1(const mechanism_configuration::v0::types::ReactionComponent &v0_component)#
template<typename Func>
decltype(func()) HandleErrors(Func func, Error *error)#
template<typename T>
T GetSpeciesProperty(MICM *micm, const char *species_name, const char *property_name, Error *error)#
static musica::RosenbrockSolverParameters ToRosenbrockParams(const RosenbrockSolverParametersC *c_params)#
static musica::BackwardEulerSolverParameters ToBackwardEulerParams(const BackwardEulerSolverParametersC *c_params)#
State *CreateMicmState(musica::MICM *micm, std::size_t number_of_grid_cells, Error *error)#
void convert_species(Chemistry &chemistry, const std::vector<mechanism_configuration::v0::types::Species> &species)#
std::vector<micm::Species> reaction_components_to_reactants(const std::vector<mechanism_configuration::v0::types::ReactionComponent> &components, std::unordered_map<std::string, micm::Species> &species_map)#
std::vector<micm::StoichSpecies> reaction_components_to_products(const std::vector<mechanism_configuration::v0::types::ReactionComponent> &components, std::unordered_map<std::string, micm::Species> &species_map)#
void convert_arrhenius(Chemistry &chemistry, const std::vector<mechanism_configuration::v0::types::Arrhenius> &arrhenius, std::unordered_map<std::string, micm::Species> &species_map)#
void convert_branched(Chemistry &chemistry, const std::vector<mechanism_configuration::v0::types::Branched> &branched, std::unordered_map<std::string, micm::Species> &species_map)#
void convert_user_defined(Chemistry &chemistry, const std::vector<mechanism_configuration::v0::types::UserDefined> &user_defined, std::unordered_map<std::string, micm::Species> &species_map)#
void convert_surface(Chemistry &chemistry, const std::vector<mechanism_configuration::v0::types::Surface> &surface, micm::Phase &gas_phase, std::unordered_map<std::string, micm::Species> &species_map)#
void convert_troe(Chemistry &chemistry, const std::vector<mechanism_configuration::v0::types::Troe> &troe, std::unordered_map<std::string, micm::Species> &species_map)#
void convert_ternary_chemical_activation(Chemistry &chemistry, const std::vector<mechanism_configuration::v0::types::TernaryChemicalActivation> &ternary_chemical_activation, std::unordered_map<std::string, micm::Species> &species_map)#
void convert_tunneling(Chemistry &chemistry, const std::vector<mechanism_configuration::v0::types::Tunneling> &tunneling, std::unordered_map<std::string, micm::Species> &species_map)#
std::vector<micm::Species> convert_species(const std::vector<mechanism_configuration::v1::types::Species> &species)#
std::vector<micm::Phase> convert_phases(const std::vector<mechanism_configuration::v1::types::Phase> &phases, std::unordered_map<std::string, micm::Species> &species_map)#
std::vector<micm::Species> reaction_components_to_reactants(const std::vector<mechanism_configuration::v1::types::ReactionComponent> &components, std::unordered_map<std::string, micm::Species> &species_map)#
std::vector<micm::StoichSpecies> reaction_components_to_products(const std::vector<mechanism_configuration::v1::types::ReactionComponent> &components, std::unordered_map<std::string, micm::Species> &species_map)#
void convert_arrhenius(Chemistry &chemistry, const std::vector<mechanism_configuration::v1::types::Arrhenius> &arrhenius, std::unordered_map<std::string, micm::Species> &species_map)#
void convert_branched(Chemistry &chemistry, const std::vector<mechanism_configuration::v1::types::Branched> &branched, std::unordered_map<std::string, micm::Species> &species_map)#
void convert_surface(Chemistry &chemistry, const std::vector<mechanism_configuration::v1::types::Surface> &surface, std::unordered_map<std::string, micm::Species> &species_map, const micm::Phase &gas_phase, const std::string &prefix)#
void convert_troe(Chemistry &chemistry, const std::vector<mechanism_configuration::v1::types::Troe> &troe, std::unordered_map<std::string, micm::Species> &species_map)#
void convert_ternary_chemical_activation(Chemistry &chemistry, const std::vector<mechanism_configuration::v1::types::TernaryChemicalActivation> &ternary, std::unordered_map<std::string, micm::Species> &species_map)#
void convert_tunneling(Chemistry &chemistry, const std::vector<mechanism_configuration::v1::types::Tunneling> &tunneling, std::unordered_map<std::string, micm::Species> &species_map)#
void convert_taylor_series(Chemistry &chemistry, const std::vector<mechanism_configuration::v1::types::TaylorSeries> &taylor_series, std::unordered_map<std::string, micm::Species> &species_map)#
void convert_lambda_rate_constants(Chemistry &chemistry, const std::vector<mechanism_configuration::v1::types::LambdaRateConstant> &reactions, std::unordered_map<std::string, micm::Species> &species_map)#
template<typename T>
void convert_user_defined(Chemistry &chemistry, const std::vector<T> &user_defined, std::unordered_map<std::string, micm::Species> &species_map, std::string prefix = "")#
void MusicaVersion(String *musica_version)#
void CreateString(const char *value, String *str)#
void DeleteString(String *str)#
void NoError(Error *error)#
void ToError(const char *category, int code, int severity, Error *error)#
void ToError(const char *category, int code, const char *message, int severity, Error *error)#
void ToError(const std::system_error &e, int severity, Error *error)#
bool IsSuccess(const Error &error)#
bool IsError(const Error &error, const char *category, int code)#
void DeleteError(Error *error)#
bool operator==(const Error &lhs, const Error &rhs)#
bool operator!=(const Error &lhs, const Error &rhs)#
void LoadConfigurationFromString(const char *data, Configuration *configuration, Error *error)#
void LoadConfigurationFromFile(const char *filename, Configuration *configuration, Error *error)#
void DeleteConfiguration(Configuration *config)#
void ToMapping(const char *name, std::size_t index, Mapping *mapping)#
Mapping *AllocateMappingArray(const std::size_t size)#
void CreateMappings(std::size_t size, Mappings *mapping)#
std::size_t FindMappingIndex(const Mappings mappings, const char *name, Error *error)#
void DeleteMapping(Mapping *mapping)#
void DeleteMappings(Mappings *mappings)#
void CreateIndexMappings(const Configuration configuration, const IndexMappingOptions map_options, const Mappings source, const Mappings target, IndexMappings *index_mapping, Error *error)#
std::size_t GetIndexMappingsSize(const IndexMappings mappings)#
void CopyData(const IndexMappings mappings, const double *source, double *target)#
void DeleteIndexMapping(IndexMapping *mapping)#
void DeleteIndexMappings(IndexMappings *mappings)#
struct BackwardEulerSolverParameters#
#include <musica/micm/solver_parameters.hpp>

Parameters for configuring Backward Euler solvers.

struct BackwardEulerSolverParametersC#
#include <musica/micm/micm_c_interface.hpp>

C-compatible struct for Backward Euler solver parameters.

class CARMA#

Public Functions

explicit CARMA(const CARMAParameters &params)#

Constructor for CARMA.

Parameters:

params – The CARMA parameters to initialize the model

Throws:

std::runtime_error – if the CARMA instance cannot be created

CARMAGroupProperties GetGroupProperties(int group_index) const#

Get properties calculated in CARMA for a specific group.

Parameters:

group_index – The index of the group to retrieve properties for

Returns:

A CARMAGroupProperties object containing the properties for the specified group

CARMAElementProperties GetElementProperties(int element_index) const#

Get properties calculated in CARMA for a specific element.

Parameters:

element_index – The index of the element to retrieve properties for

Returns:

A CARMAElementProperties object containing the properties for the specified element

Public Static Functions

static std::string GetVersion()#

Get the version of CARMA.

Returns:

The version string of the CARMA instance

static struct CCARMAParameters *ToCCompatible(const CARMAParameters &params)#

Convert CARMAParameters to C-compatible CCARMAParameters.

Parameters:

params – The C++ CARMA parameters to convert

Returns:

The C-compatible CARMA parameters structure

static void FreeCCompatible(struct CCARMAParameters *c_params)#

Free memory allocated in CCARMAParameters.

Parameters:

c_params – The C-compatible parameters to clean up

static CARMAParameters CreateAluminumTestParams()#

Returns a set of test parameters for the aluminum test case.

Returns:

A CARMAParameters object with the aluminum test case configuration

struct CarmaBinValues#
struct CARMACoagulationConfig#
struct CARMACoagulationConfigC#
struct CARMAComplex#
struct CARMAComplexC#
struct CarmaDetrainValues#
struct CARMAElementConfig#
struct CARMAElementConfigC#
struct CARMAElementProperties#
struct CARMAElementPropertiesC#
struct CarmaEnvironmentalValues#
struct CARMAGasConfig#
struct CARMAGasConfigC#
struct CarmaGasValues#
struct CARMAGroupConfig#
struct CARMAGroupConfigC#
struct CARMAGroupProperties#
struct CARMAGrowthConfig#
struct CARMAGrowthConfigC#
struct CARMAInitializationConfig#
struct CARMAInitializationConfigC#
struct CARMANucleationConfig#
struct CARMANucleationConfigC#
struct CARMAOutputDataC#
struct CARMAParameters#
struct CARMASoluteConfig#
struct CARMASoluteConfigC#
class CARMAState#

Public Functions

void SetBin(int bin_index, int element_index, const std::vector<double> &values, const double surface_mass)#

Set the values for a specific bin and element.

Parameters:
  • bin_index – The index of the bin

  • element_index – The index of the particle element

  • values – Bin mixing ratio at vertical centers [kg/kg]

  • surface_mass – Element mass on the surface [kg m-2] (0: off)

void SetDetrain(int bin_index, int element_index, const std::vector<double> &values)#

Set the mass of the detrained condensate for the bin for each particle element.

Parameters:
  • bin_index – The index of the bin

  • element_index – The index of the particle element

  • values – Bin mixing ratio at vertical centers [kg/kg]

void SetGas(int gas_index, const std::vector<double> &values, const std::vector<double> &old_mmr, const std::vector<double> &gas_saturation_wrt_ice, const std::vector<double> &gas_saturation_wrt_liquid)#

Set the gas profile.

Parameters:
  • gas_index – The index of the gas

  • values – Mass mixing ratios at vertical centers [kg/kg]

  • old_mmr – Original mass mixing ratios at vertical centers [kg/kg]

  • gas_saturation_wrt_ice – The gas saturation with respect to ice [fraction]

  • gas_saturation_wrt_liquid – The gas saturation with respect to liquid [fraction]

void SetTemperature(const std::vector<double> &temperature)#

Set the temperature profile.

Parameters:

temperature – The temperature profile [K] (number of vertical centers)

void SetAirDensity(const std::vector<double> &air_density)#

Set the air density profile.

Parameters:

air_density – The air density profile [kg/m3] (number of vertical centers)

struct CARMAStateParameters#
struct CARMAStateParametersC#
struct CARMAStateStepConfig#
struct CARMAStateStepConfigC#
struct CarmaStatistics#
struct CARMASurfaceProperties#
struct CARMASurfacePropertiesC#
struct CARMASwellingApproach#
struct CARMAWavelengthBin#
struct CARMAWavelengthBinC#
struct CCARMAParameters#
struct Chemistry#
class CpuSolver : public musica::IMicmSolver#
#include <musica/micm/cpu_solver.hpp>

CPU solver implementation using internal variant.

Public Functions

CpuSolver(const Chemistry &chemistry, int solver_type)#

Construct a CPU solver from chemistry configuration.

Parameters:
  • chemistry – The chemistry configuration

  • solver_type – The type of solver to create

virtual micm::SolverResult Solve(IState *state, double time_step) override#

Solve the chemical system for a given time step.

Parameters:
  • state – The state object containing concentrations and conditions

  • time_step – Time [s] to advance the state by

Returns:

Solver result containing status and statistics

virtual std::size_t MaximumNumberOfGridCells() const override#

Get the maximum number of grid cells this solver can handle.

Returns:

Maximum number of grid cells per state

virtual std::unique_ptr<IState> CreateState(std::size_t number_of_grid_cells) override#

Create a new state object compatible with this solver.

Parameters:

number_of_grid_cells – Number of grid cells for the state

Returns:

Unique pointer to a new IState implementation

virtual micm::System GetSystem() const override#

Get the chemical system configuration.

Returns:

The MICM System object

virtual std::unordered_map<std::string, std::size_t> GetSpeciesOrdering() const override#

Get the species ordering map.

Returns:

Map of species names to their indices

virtual std::unordered_map<std::string, std::size_t> GetRateParameterOrdering() const override#

Get the rate parameter ordering map.

Returns:

Map of rate parameter names to their indices

virtual std::size_t GetVectorSize() const override#

Get the vector size for this solver type.

Returns:

Vector dimension for vector-ordered solvers, 1 for standard-ordered solvers

virtual void SetRosenbrockSolverParameters(const RosenbrockSolverParameters &params) override#

Set Rosenbrock solver parameters.

Parameters:

params – The parameters to set

Throws:

std::system_error – if the solver is not a Rosenbrock solver

virtual void SetBackwardEulerSolverParameters(const BackwardEulerSolverParameters &params) override#

Set Backward Euler solver parameters.

Parameters:

params – The parameters to set

Throws:

std::system_error – if the solver is not a Backward Euler solver

virtual RosenbrockSolverParameters GetRosenbrockSolverParameters() const override#

Get Rosenbrock solver parameters.

Throws:

std::system_error – if the solver is not a Rosenbrock solver

Returns:

The current parameters

virtual BackwardEulerSolverParameters GetBackwardEulerSolverParameters() const override#

Get Backward Euler solver parameters.

Throws:

std::system_error – if the solver is not a Backward Euler solver

Returns:

The current parameters

struct CpuSolverVisitor#

Visitor struct to handle different solver and state type combinations.

class CpuState : public musica::IState#
#include <musica/micm/cpu_solver.hpp>

CPU state implementation wrapping VectorState or StandardState.

Public Functions

virtual std::size_t NumberOfGridCells() const override#

Get the number of grid cells.

Returns:

Number of grid cells

virtual std::size_t NumberOfSpecies() const override#

Get the number of species.

Returns:

Number of species

virtual std::size_t NumberOfUserDefinedRateParameters() const override#

Get the number of user-defined rate parameters.

Returns:

Number of user-defined rate parameters

virtual std::vector<micm::Conditions> &GetConditions() override#

Get the vector of conditions.

Returns:

Reference to vector of conditions

virtual const std::vector<micm::Conditions> &GetConditions() const override#

Get the vector of conditions (const version)

Returns:

Const reference to vector of conditions

virtual std::vector<double> &GetOrderedConcentrations() override#

Get the ordered concentrations vector.

Returns:

Reference to the concentrations vector

virtual const std::vector<double> &GetOrderedConcentrations() const override#

Get the ordered concentrations vector (const version)

Returns:

Const reference to the concentrations vector

virtual std::vector<double> &GetOrderedRateParameters() override#

Get the ordered rate parameters vector.

Returns:

Reference to the rate parameters vector

virtual const std::vector<double> &GetOrderedRateParameters() const override#

Get the ordered rate parameters vector (const version)

Returns:

Const reference to the rate parameters vector

virtual std::pair<std::size_t, std::size_t> GetConcentrationsStrides() const override#

Get the strides for the concentration matrix.

Returns:

Pair of (row_stride, column_stride)

virtual std::pair<std::size_t, std::size_t> GetRateParameterStrides() const override#

Get the strides for the rate parameter matrix.

Returns:

Pair of (row_stride, column_stride)

virtual std::unordered_map<std::string, std::size_t> GetVariableMap() const override#

Get the variable (species) ordering map.

Returns:

Map of species names to their indices

virtual std::unordered_map<std::string, std::size_t> GetRateParameterMap() const override#

Get the rate parameter ordering map.

Returns:

Map of rate parameter names to their indices

StateVariant &GetStateVariant()#

Get access to the underlying state variant for solving.

class CudaLoader#
#include <musica/micm/cuda_loader.hpp>

Singleton class for runtime loading of CUDA solvers Uses dlopen/dlsym on Linux to load libmusica_cuda.so at runtime. This allows a single library to work both with and without CUDA.

Public Functions

bool IsAvailable() const#

Check if the CUDA library was loaded successfully.

Returns:

true if libmusica_cuda.so is loaded and functional

bool HasDevices() const#

Check if CUDA devices are available on this system.

Returns:

true if CUDA devices are present and usable

CudaSolverPtr CreateRosenbrockSolver(const Chemistry &chemistry)#

Create a CUDA Rosenbrock solver.

Parameters:

chemistry – The chemistry configuration

Throws:

std::runtime_error – if CUDA is not available

Returns:

Unique pointer to the created solver with custom deleter

void CleanUp()#

Clean up CUDA resources Should be called before program exit when CUDA was used.

std::string GetLastError() const#

Get the last error message.

Returns:

The last error message, or empty string if no error

Public Static Functions

static CudaLoader &GetInstance()#

Get the singleton instance.

struct CudaSolverDeleter#
#include <musica/micm/cuda_loader.hpp>

Custom deleter for CUDA solvers that uses the plugin’s destroy function.

class Grid#
#include <musica/tuvx/grid.hpp>

A grid class used to access grid information in tuvx.

Public Functions

Grid(const char *grid_name, const char *units, std::size_t num_sections, Error *error)#

Creates a grid instance.

Parameters:
  • grid_name – The name of the grid

  • units – The units of the grid

  • num_sections – The number of sections in the grid

  • error – The error struct to indicate success or failure

std::string GetName(Error *error)#

Get the name of the grid.

Parameters:

error – The error struct to indicate success or failure

Returns:

The name of the grid

std::string GetUnits(Error *error)#

Get the units of the grid.

Parameters:

error – The error struct to indicate success or failure

Returns:

The units of the grid

std::size_t GetNumberOfSections(Error *error)#

Return the number of sections in the grid.

Parameters:

error – The error struct to indicate success or failure

Returns:

The number of sections in the grid

void SetEdges(double edges[], std::size_t num_edges, Error *error)#

Set the edges of the grid.

Parameters:
  • edges – The edges of the grid

  • num_edges – the number of edges

  • error – the error struct to indicate success or failure

void GetEdges(double edges[], std::size_t num_edges, Error *error)#

Get the edges of the grid.

Parameters:
  • edges – The edges of the grid

  • num_edges – the number of edges

  • error – the error struct to indicate success or failure

double *GetEdgesPointer(Error *error)#

Return a pointer to the edges array.

Parameters:

error – the error struct to indicate success or failure

Returns:

A pointer to the edges array

void SetMidpoints(double midpoints[], std::size_t num_midpoints, Error *error)#

Set the midpoints of the grid.

Parameters:
  • midpoints – The midpoints of the grid

  • num_midpoints – the number of midpoints

  • error – the error struct to indicate success or failure

void GetMidpoints(double midpoints[], std::size_t num_midpoints, Error *error)#

Get the midpoints of the grid.

Parameters:
  • midpoints – The midpoints of the grid

  • num_midpoints – the number of midpoints

  • error – the error struct to indicate success or failure

double *GetMidpointsPointer(Error *error)#

Return a pointer to the midpoints array.

Parameters:

error – the error struct to indicate success or failure

Returns:

A pointer to the midpoints array

class GridMap#
#include <musica/tuvx/grid_map.hpp>

A grid map class used to access grid information in tuvx.

Public Functions

GridMap(Error *error)#

Creates a grid map instance.

Parameters:

error – The error struct to indicate success or failure

void AddGrid(Grid *grid, Error *error)#

Adds a grid to the grid map.

Parameters:
  • grid – The grid to add

  • error – The error struct to indicate success or failure

Grid *GetGrid(const char *grid_name, const char *grid_units, Error *error)#

Returns a grid. For now, this calls the interal tuvx fortran api, but will allow the change to c++ later on to be transparent to downstream projects.

Parameters:
  • grid_name – The name of the grid we want

  • grid_units – The units of the grid we want

  • error – The error struct to indicate success or failure

Returns:

a grid pointer

Grid *GetGridByIndex(std::size_t index, Error *error)#

Gets a grid by index in the map.

Parameters:
  • index – The index of the grid we want

  • error – The error struct to indicate success or failure

Returns:

a grid pointer

void RemoveGrid(const char *grid_name, const char *grid_units, Error *error)#

Removes a grid from the map.

Parameters:
  • grid_name – The name of the grid to remove

  • grid_units – The units of the grid to remove

  • error – The error struct to indicate success or failure

void RemoveGridByIndex(std::size_t index, Error *error)#

Removes a grid from the map by index.

Parameters:
  • index – The index of the grid to remove

  • error – The error struct to indicate success or failure

std::size_t GetNumberOfGrids(Error *error)#

Gets the number of grids in the map.

Parameters:

error – The error struct to indicate success or failure

Returns:

the number of grids in the map

template<typename T, typename = void>
struct has_products : public std::false_type#
template<typename T>
struct has_products<T, std::void_t<decltype(std::declval<T>().products)>> : public std::false_type, public std::true_type#
template<typename T, typename = void>
struct has_reactants : public std::false_type#
template<typename T>
struct has_reactants<T, std::void_t<decltype(std::declval<T>().reactants)>> : public std::false_type, public std::true_type#
class IMicmSolver#
#include <musica/micm/solver_interface.hpp>

Abstract interface for type-erased MICM solvers This interface enables runtime polymorphism for different solver types (CPU and CUDA) without compile-time variant changes.

Subclassed by musica::CpuSolver, musica::cuda::CudaRosenbrockSolver

Public Functions

virtual micm::SolverResult Solve(IState *state, double time_step) = 0#

Solve the chemical system for a given time step.

Parameters:
  • state – The state object containing concentrations and conditions

  • time_step – Time [s] to advance the state by

Returns:

Solver result containing status and statistics

virtual std::size_t MaximumNumberOfGridCells() const = 0#

Get the maximum number of grid cells this solver can handle.

Returns:

Maximum number of grid cells per state

virtual std::unique_ptr<IState> CreateState(std::size_t number_of_grid_cells) = 0#

Create a new state object compatible with this solver.

Parameters:

number_of_grid_cells – Number of grid cells for the state

Returns:

Unique pointer to a new IState implementation

virtual micm::System GetSystem() const = 0#

Get the chemical system configuration.

Returns:

The MICM System object

virtual std::unordered_map<std::string, std::size_t> GetSpeciesOrdering() const = 0#

Get the species ordering map.

Returns:

Map of species names to their indices

virtual std::unordered_map<std::string, std::size_t> GetRateParameterOrdering() const = 0#

Get the rate parameter ordering map.

Returns:

Map of rate parameter names to their indices

virtual std::size_t GetVectorSize() const = 0#

Get the vector size for this solver type.

Returns:

Vector dimension for vector-ordered solvers, 1 for standard-ordered solvers

inline virtual void SetRosenbrockSolverParameters(const RosenbrockSolverParameters &params)#

Set Rosenbrock solver parameters.

Parameters:

params – The parameters to set

Throws:

std::system_error – if the solver is not a Rosenbrock solver

inline virtual void SetBackwardEulerSolverParameters(const BackwardEulerSolverParameters &params)#

Set Backward Euler solver parameters.

Parameters:

params – The parameters to set

Throws:

std::system_error – if the solver is not a Backward Euler solver

inline virtual RosenbrockSolverParameters GetRosenbrockSolverParameters() const#

Get Rosenbrock solver parameters.

Throws:

std::system_error – if the solver is not a Rosenbrock solver

Returns:

The current parameters

inline virtual BackwardEulerSolverParameters GetBackwardEulerSolverParameters() const#

Get Backward Euler solver parameters.

Throws:

std::system_error – if the solver is not a Backward Euler solver

Returns:

The current parameters

class IState#
#include <musica/micm/state_interface.hpp>

Abstract interface for type-erased MICM states This interface enables runtime polymorphism for different state types (CPU vector, CPU standard, and CUDA) without compile-time variant changes.

Subclassed by musica::CpuState, musica::cuda::CudaState

Public Functions

virtual std::size_t NumberOfGridCells() const = 0#

Get the number of grid cells.

Returns:

Number of grid cells

virtual std::size_t NumberOfSpecies() const = 0#

Get the number of species.

Returns:

Number of species

virtual std::size_t NumberOfUserDefinedRateParameters() const = 0#

Get the number of user-defined rate parameters.

Returns:

Number of user-defined rate parameters

virtual std::vector<micm::Conditions> &GetConditions() = 0#

Get the vector of conditions.

Returns:

Reference to vector of conditions

virtual const std::vector<micm::Conditions> &GetConditions() const = 0#

Get the vector of conditions (const version)

Returns:

Const reference to vector of conditions

virtual std::vector<double> &GetOrderedConcentrations() = 0#

Get the ordered concentrations vector.

Returns:

Reference to the concentrations vector

virtual const std::vector<double> &GetOrderedConcentrations() const = 0#

Get the ordered concentrations vector (const version)

Returns:

Const reference to the concentrations vector

virtual std::vector<double> &GetOrderedRateParameters() = 0#

Get the ordered rate parameters vector.

Returns:

Reference to the rate parameters vector

virtual const std::vector<double> &GetOrderedRateParameters() const = 0#

Get the ordered rate parameters vector (const version)

Returns:

Const reference to the rate parameters vector

virtual std::pair<std::size_t, std::size_t> GetConcentrationsStrides() const = 0#

Get the strides for the concentration matrix.

Returns:

Pair of (row_stride, column_stride)

virtual std::pair<std::size_t, std::size_t> GetRateParameterStrides() const = 0#

Get the strides for the rate parameter matrix.

Returns:

Pair of (row_stride, column_stride)

virtual std::unordered_map<std::string, std::size_t> GetVariableMap() const = 0#

Get the variable (species) ordering map.

Returns:

Map of species names to their indices

virtual std::unordered_map<std::string, std::size_t> GetRateParameterMap() const = 0#

Get the rate parameter ordering map.

Returns:

Map of rate parameter names to their indices

class MICM#

Public Functions

micm::SolverResult Solve(musica::State *state, double time_step)#

Solve the system.

Parameters:
  • state – Pointer to state object

  • time_step – Time [s] to advance the state by

template<class T>
inline T GetSpeciesProperty(const std::string &species_name, const std::string &property_name)#

Get a property for a chemical species.

Parameters:
  • species_name – Name of the species

  • property_name – Name of the property

Returns:

Value of the property

std::size_t GetMaximumNumberOfGridCells()#

Get the maximum number of grid cells per state.

Returns:

Maximum number of grid cells

std::unique_ptr<IState> CreateState(std::size_t number_of_grid_cells)#

Create a new state object for this solver.

Parameters:

number_of_grid_cells – Number of grid cells for the state

Returns:

Unique pointer to a new IState implementation

micm::System GetSystem() const#

Get the chemical system configuration.

Returns:

The MICM System object

std::unordered_map<std::string, std::size_t> GetSpeciesOrdering() const#

Get the species ordering map.

Returns:

Map of species names to their indices

std::unordered_map<std::string, std::size_t> GetRateParameterOrdering() const#

Get the rate parameter ordering map.

Returns:

Map of rate parameter names to their indices

MICMSolver GetSolverType() const#

Get the solver type.

Returns:

The solver type enum value

std::size_t GetVectorSize() const#

Get the vector size for this solver type.

Returns:

Vector dimension for vector-ordered solvers, 1 for standard-ordered solvers

IMicmSolver *GetSolverInterface()#

Get access to the underlying solver interface.

Returns:

Pointer to the IMicmSolver implementation

void SetSolverParameters(const RosenbrockSolverParameters &params)#

Set Rosenbrock solver parameters.

Parameters:

params – The parameters to set

void SetSolverParameters(const BackwardEulerSolverParameters &params)#

Set Backward Euler solver parameters.

Parameters:

params – The parameters to set

RosenbrockSolverParameters GetRosenbrockSolverParameters() const#

Get Rosenbrock solver parameters.

Returns:

The current parameters

BackwardEulerSolverParameters GetBackwardEulerSolverParameters() const#

Get Backward Euler solver parameters.

Returns:

The current parameters

class Profile#
#include <musica/tuvx/profile.hpp>

A class used to interact with TUV-x profiles (properties with values on a grid)

Public Functions

Profile(const char *profile_name, const char *units, Grid *grid, Error *error)#

Creates a profile instance.

Parameters:
  • profile_name – The name of the profile

  • units – The units of the profile

  • grid – The grid to use for the profile

  • error – The error struct to indicate success or failure

std::string GetName(Error *error)#

Get the name of the profile.

Parameters:

error – The error struct to indicate success or failure

Returns:

The name of the profile

std::string GetUnits(Error *error)#

Get the units of the profile.

Parameters:

error – The error struct to indicate success or failure

Returns:

The units of the profile

void SetEdgeValues(double edge_values[], std::size_t num_values, Error *error)#

Sets the profile values at the edges of the grid.

Parameters:
  • edge_values – The values at the edges of the grid

  • num_values – The number of values

  • error – The error struct to indicate success or failure

void GetEdgeValues(double edge_values[], std::size_t num_values, Error *error)#

Gets the profile values at the edges of the grid.

Parameters:
  • edge_values – The values at the edges of the grid

  • num_values – The number of values

  • error – The error struct to indicate success or failure

double *GetEdgeValuesPointer(Error *error)#

Returns a pointer to the edge values array.

Parameters:

error – The error struct to indicate success or failure

Returns:

A pointer to the edge values array

void SetMidpointValues(double midpoint_values[], std::size_t num_values, Error *error)#

Sets the profile values at the midpoints of the grid.

Parameters:
  • midpoint_values – The values at the midpoints of the grid

  • num_values – The number of values

  • error – The error struct to indicate success or failure

void GetMidpointValues(double midpoint_values[], std::size_t num_values, Error *error)#

Gets the profile values at the midpoints of the grid.

Parameters:
  • midpoint_values – The values at the midpoints of the grid

  • num_values – The number of values

  • error – The error struct to indicate success or failure

double *GetMidpointValuesPointer(Error *error)#

Returns a pointer to the midpoint values array.

Parameters:

error – The error struct to indicate success or failure

Returns:

A pointer to the midpoint values array

void SetLayerDensities(double layer_densities[], std::size_t num_values, Error *error)#

Sets the layer densities for each grid section.

Parameters:
  • layer_densities – The layer densities

  • num_values – The number of values

  • error – The error struct to indicate success or failure

void GetLayerDensities(double layer_densities[], std::size_t num_values, Error *error)#

Gets the layer densities for each grid section.

Parameters:
  • layer_densities – The layer densities

  • num_values – The number of values

  • error – The error struct to indicate success or failure

double *GetLayerDensitiesPointer(Error *error)#

Returns a pointer to the layer densities array.

Parameters:

error – The error struct to indicate success or failure

Returns:

A pointer to the layer densities array

void SetExoLayerDensity(double exo_layer_density, Error *error)#

Sets the layer density above the top of the grid.

Parameters:
  • exo_layer_density – The layer density above the top of the grid

  • error – The error struct to indicate success or failure

void CalculateExoLayerDensity(double scale_height, Error *error)#

Calculates an exo layer density based on a provided scale height.

Parameters:
  • scale_height – The scale height to use in the calculation

  • error – The error struct to indicate success or failure

double GetExoLayerDensity(Error *error)#

Gets the layer density above the top of the grid.

Parameters:

error – The error struct to indicate success or failure

Returns:

The layer density above the top of the grid

std::size_t GetNumberOfSections(Error *error)#

Gets the number of sections in the profile’s grid.

Parameters:

error – The error struct to indicate success or failure

Returns:

The number of sections in the profile’s grid

class ProfileMap#
#include <musica/tuvx/profile_map.hpp>

A class used to store a collection of profiles.

Public Functions

ProfileMap(Error *error)#

Creates a profile map instance.

Parameters:

error – The error struct to indicate success or failure

void AddProfile(Profile *profile, Error *error)#

Adds a profile to the profile map.

Parameters:
  • profile – The profile to add

  • error – The error struct to indicate success or failure

Profile *GetProfile(const char *profile_name, const char *profile_units, Error *error)#

Returns a profile. For now, this calls the interal tuvx fortran api, but will allow the change to c++ later on to be transparent to downstream projects.

Parameters:
  • profile_name – The name of the profile we want

  • profile_units – The units of the profile we want

  • error – The error struct to indicate success or failure

Returns:

a profile pointer

Profile *GetProfileByIndex(std::size_t index, Error *error)#

Returns a profile by index in the map.

Parameters:
  • index – The index of the profile we want

  • error – The error struct to indicate success or failure

Returns:

a profile pointer

void RemoveProfile(const char *profile_name, const char *profile_units, Error *error)#

Removes a profile from the map by name and units.

Parameters:
  • profile_name – The name of the profile to remove

  • profile_units – The units of the profile to remove

  • error – The error struct to indicate success or failure

void RemoveProfileByIndex(std::size_t index, Error *error)#

Removes a profile from the map by index.

Parameters:
  • index – The index of the profile to remove

  • error – The error struct to indicate success or failure

std::size_t GetNumberOfProfiles(Error *error)#

Gets the number of profiles in the map.

Parameters:

error – The error struct to indicate success or failure

Returns:

The number of profiles in the map

class Radiator#
#include <musica/tuvx/radiator.hpp>

Radiator class used to access radiator information in tuvx.

Public Functions

Radiator(const char *radiator_name, Grid *height_grid, Grid *wavelength_grid, Error *error)#

Creates radiator.

Parameters:
  • radiator_nameRadiator name

  • height_grid – Height grid

  • wavelength_grid – Wavelength grid

  • error – Error to indicate success or failure

std::string GetName(Error *error)#

Get the name of the radiator.

Parameters:

error – The error struct to indicate success or failure

Returns:

The name of the radiator

void SetOpticalDepths(double *optical_depths, std::size_t num_vertical_layers, std::size_t num_wavelength_bins, Error *error)#

Sets optical depth values.

Parameters:
  • optical_depths – 2D array of optical depth values

  • num_vertical_layers – Number of vertical layers

  • num_wavelength_bins – Number of wavelength bins

  • error – Error to indicate success or failure

void GetOpticalDepths(double *optical_depths, std::size_t num_vertical_layers, std::size_t num_wavelength_bins, Error *error)#

Gets optical depth values.

Parameters:
  • optical_depths – 2D array of optical depth values

  • num_vertical_layers – Number of vertical layers

  • num_wavelength_bins – Number of wavelength bins

  • error – Error to indicate success or failure

double *GetOpticalDepthsPointer(Error *error)#

Returns a pointer to the optical depths array.

Parameters:

error – Error to indicate success or failure

Returns:

A pointer to the optical depths array

void SetSingleScatteringAlbedos(double *single_scattering_albedos, std::size_t num_vertical_layers, std::size_t num_wavelength_bins, Error *error)#

Sets single scattering albedos values.

Parameters:
  • single_scattering_albedos – 2D array of single scattering albedos values

  • num_vertical_layers – Number of vertical layers

  • num_wavelength_bins – Number of wavelength bins

  • error – Error to indicate success or failure

void GetSingleScatteringAlbedos(double *single_scattering_albedos, std::size_t num_vertical_layers, std::size_t num_wavelength_bins, Error *error)#

Gets single scattering albedos values.

Parameters:
  • single_scattering_albedos – 2D array of single scattering albedos values

  • num_vertical_layers – Number of vertical layers

  • num_wavelength_bins – Number of wavelength bins

  • error – Error to indicate success or failure

double *GetSingleScatteringAlbedosPointer(Error *error)#

Return a pointer to the single scattering albedos array.

Parameters:

error – Error to indicate success or failure

Returns:

A pointer to the single scattering albedos array

void SetAsymmetryFactors(double *asymmetry_factor, std::size_t num_vertical_layers, std::size_t num_wavelength_bins, std::size_t num_streams, Error *error)#

Sets asymmetry factor values.

Parameters:
  • asymmetry_factor – 3D array of asymmetery factor values

  • num_vertical_layers – Number of vertical layers

  • num_wavelength_bins – Number of wavelength bins

  • num_streams – Number of streams

  • error – Error to indicate success or failure

void GetAsymmetryFactors(double *asymmetry_factor, std::size_t num_vertical_layers, std::size_t num_wavelength_bins, std::size_t num_streams, Error *error)#

Gets asymmetry factor values.

Parameters:
  • asymmetry_factor – 3D array of asymmetery factor values

  • num_vertical_layers – Number of vertical layers

  • num_wavelength_bins – Number of wavelength bins

  • num_streams – Number of streams

  • error – Error to indicate success or failure

double *GetAsymmetryFactorsPointer(Error *error)#

Return a pointer to the asymmetry factors array.

Parameters:

error – Error to indicate success or failure

Returns:

A pointer to the asymmetry factors array

std::size_t GetNumberOfHeightSections(Error *error)#

Return the number of sections in the radiator’s height grid.

Parameters:

error – The error struct to indicate success or failure

Returns:

The number of sections in the radiator’s height grid

std::size_t GetNumberOfWavelengthSections(Error *error)#

Return the number of sections in the radiator’s wavelength grid.

Parameters:

error – The error struct to indicate success or failure

Returns:

The number of sections in the radiator’s wavelength grid

class RadiatorMap#
#include <musica/tuvx/radiator_map.hpp>

Radiator map used to access radiator information in tuvx.

Public Functions

RadiatorMap(Error *error)#

Creates radiator map.

Parameters:

error – Error to indicate success or failure

void AddRadiator(Radiator *radiator, Error *error)#

Adds a radiator to the radiator map.

Parameters:
  • radiatorRadiator to add

  • error – Error to indicate success or failure

Radiator *GetRadiator(const char *radiator_name, Error *error)#

Returns a radiator. For now, this calls the interal tuvx fortran api, but will allow the change to c++ later on to be transparent to downstream projects.

Parameters:
  • radiator_nameRadiator name

  • error – Error to indicate success or failure

Returns:

Radiator

Radiator *GetRadiatorByIndex(std::size_t index, Error *error)#

Returns a radiator based on its index in the map.

Parameters:
  • index – Index of the radiator we want

  • error – Error to indicate success or failure

Returns:

Radiator

void RemoveRadiator(const char *radiator_name, Error *error)#

Removes a radiator from the map by name.

Parameters:
  • radiator_nameRadiator name

  • error – Error to indicate success or failure

void RemoveRadiatorByIndex(std::size_t index, Error *error)#

Removes a radiator from the map by index.

Parameters:
  • index – Index of the radiator to remove

  • error – Error to indicate success or failure

std::size_t GetNumberOfRadiators(Error *error)#

Gets the number of radiators in the map.

Parameters:

error – Error to indicate success or failure

Returns:

Number of radiators in the map

struct RosenbrockSolverParameters#
#include <musica/micm/solver_parameters.hpp>

Parameters for configuring Rosenbrock solvers.

struct RosenbrockSolverParametersC#
#include <musica/micm/micm_c_interface.hpp>

C-compatible struct for Rosenbrock solver parameters.

class State#

Public Functions

explicit State(std::unique_ptr<IState> impl)#

Construct a State from an IState implementation.

Parameters:

impl – The IState implementation to wrap

State(const musica::MICM &micm, std::size_t number_of_grid_cells)#

Construct a State from a MICM solver and grid cell count.

Parameters:
  • micm – The MICM solver to create state for

  • number_of_grid_cells – Number of grid cells

std::size_t NumberOfGridCells()#

Get the number of grid cells.

Returns:

Number of grid cells

std::size_t NumberOfSpecies()#

Get the number of species.

Returns:

Number of species

std::size_t NumberOfUserDefinedRateParameters()#

Get the number of user-defined rate parameters.

Returns:

Number of user-defined rate parameters

std::vector<micm::Conditions> &GetConditions()#

Get the vector of conditions struct.

Returns:

Vector of conditions struct

void SetConditions(const std::vector<micm::Conditions> &conditions)#

Set the conditions struct to the state variant.

Parameters:

conditions – Vector of conditions

std::vector<double> &GetOrderedConcentrations()#

Get the vector of concentrations.

Returns:

Vector of doubles

void SetOrderedConcentrations(const std::vector<double> &concentrations)#

Set the concentrations to the state variant.

Parameters:

concentrations – Vector of concentrations

void SetConcentrations(const std::map<std::string, std::vector<double>> &input, musica::MICMSolver solver_type)#

Set the concentrations from a map of species name to concentration vectors.

Parameters:
  • input – a mapping of species name to concentrations per grid cell

  • solver_type – The solver type to use for ordering

std::map<std::string, std::vector<double>> GetConcentrations(musica::MICMSolver solver_type) const#

Get the concentrations as a map of species name to concentration vectors.

Returns:

Map of species name to concentration vectors

void SetRateConstants(const std::map<std::string, std::vector<double>> &input, musica::MICMSolver solver_type)#

Set the rate constants from a map of species name to rate constant vectors.

Parameters:
  • input – a mapping of species name to rate constants per grid cell

  • solver_type – The solver type to use for ordering

std::map<std::string, std::vector<double>> GetRateConstants(musica::MICMSolver solver_type) const#

Get the rate constants as a map of species name to rate constant vectors.

Returns:

Map of species name to rate constant vectors

std::vector<double> &GetOrderedRateParameters()#

Get the vector of rate constants.

Returns:

Vector of doubles

void SetOrderedRateConstants(const std::vector<double> &rateConstant)#

Set the rate constants to the state variant.

Parameters:

rateConstant – Vector of Rate constants

std::pair<std::size_t, std::size_t> GetConcentrationsStrides()#

Get the underlying strides for the concentration matrix.

Returns:

Strides for the concentration matrix (grid cells, species)

std::pair<std::size_t, std::size_t> GetUserDefinedRateParametersStrides()#

Get the underlying strides for the user-defined rate parameter matrix.

Returns:

Strides for the rate parameter matrix (grid cells, rate parameters)

std::unordered_map<std::string, std::size_t> GetVariableMap() const#

Get the variable (species) ordering map.

Returns:

Map of species names to their indices

std::unordered_map<std::string, std::size_t> GetRateParameterMap() const#

Get the rate parameter ordering map.

Returns:

Map of rate parameter names to their indices

IState *GetStateInterface()#

Get the underlying IState interface for use with solvers.

Returns:

Pointer to the IState implementation

class TUVX#

Public Functions

void Create(const char *config_path, GridMap *grids, ProfileMap *profiles, RadiatorMap *radiators, Error *error)#

Create an instance of tuvx from a configuration file.

Parameters:
  • config_path – Path to configuration file

  • gridsGrid map from host application

  • profilesProfile map from host application

  • radiatorsRadiator map from host application

  • error – Error struct to indicate success or failure

void CreateFromConfigString(const char *config_string, GridMap *grids, ProfileMap *profiles, RadiatorMap *radiators, Error *error)#

Create an instance of TUV-x from a JSON/YAML string All parameters (solar zenith angle, Earth-Sun distance, atmospheric profiles, etc.) are read from the JSON configuration file, similar to the Fortran tuvx.F90 driver.

Parameters:
  • config_string – JSON/YAML configuration string

  • gridsGrid map from host application

  • profilesProfile map from host application

  • radiatorsRadiator map from host application

  • error – Error struct to indicate success or failure

GridMap *GetGridMap(Error *error)#

Returns a copy of the internal grid map. For now, this calls the interal tuvx fortran api, but will allow the change to c++ later on to be transparent to downstream projects.

Parameters:

error – The error struct to indicate success or failure

Returns:

a grid map pointer

ProfileMap *GetProfileMap(Error *error)#

Returns a copy of the internal profile map. For now, this calls the interal tuvx fortran api, but will allow the change to c++ later on to be transparent to downstream projects.

Parameters:

error – The error struct to indicate success or failure

Returns:

a profile map pointer

RadiatorMap *GetRadiatorMap(Error *error)#

Returns a copy of the internal radiator map. For now, this calls the interal tuvx fortran api, but will allow the change to c++ later on to be transparent to downstream projects.

Parameters:

error – The error struct to indicate success or failure

Returns:

a radiator map pointer

void GetPhotolysisRateConstantsOrdering(Mappings *mappings, Error *error)#

Returns the ordering of photolysis rate constants.

Parameters:

error – Error struct to indicate success or failure

Returns:

Array of photolysis rate constant name-index pairs

void GetHeatingRatesOrdering(Mappings *mappings, Error *error)#

Returns the ordering of heating rates.

Parameters:

error – Error struct to indicate success or failure

Returns:

Array of heating rate name-index pairs

void GetDoseRatesOrdering(Mappings *mappings, Error *error)#

Returns the ordering of dose rates.

Parameters:

error – Error struct to indicate success or failure

Returns:

Array of dose rate name-index pairs

void Run(const double solar_zenith_angle, const double earth_sun_distance, double *const photolysis_rate_constants, double *const heating_rates, double *const dose_rates, double *const actinic_flux, double *const spectral_irradiance, Error *const error)#

Run the TUV-x photolysis calculator.

Parameters:
  • solar_zenith_angle – Solar zenith angle [radians]

  • earth_sun_distance – Earth-Sun distance [AU]

  • photolysis_rate_constants – Photolysis rate constant [s^-1] (reaction, vertical edge)

  • heating_rates – Heating rates [K/s] (heating_reaction, vertical edge)

  • dose_rates – Dose rates [W/m^2] (dose_rate type, vertical edge)

  • actinic_flux – Actinic flux [photons cm^-2 s^-1 nm^-1] (wavelength, vertical edge, direct/upwelling/downwelling)

  • spectral_irradiance – Spectral irradiance [W/m^2 nm^-1] (wavelength, vertical edge, direct/upwelling/downwelling)

  • error – Error struct to indicate success or failure

int GetPhotolysisRateConstantCount()#

Get the number of photolysis reactions.

Throws:

std::runtime_error – if operation fails

Returns:

Number of photolysis reactions

int GetHeatingRateCount()#

Get the number of heating rate types.

Throws:

std::runtime_error – if operation fails

Returns:

Number of heating rate types

int GetDoseRateCount()#

Get the number of dose rate types.

Throws:

std::runtime_error – if operation fails

Returns:

Number of dose rate types

int GetNumberOfHeightMidpoints()#

Get the number of vertical layers.

Throws:

std::runtime_error – if operation fails

Returns:

Number of vertical layers

int GetNumberOfWavelengthMidpoints()#

Get the number of wavelength midpoints.

Throws:

std::runtime_error – if operation fails

Returns:

Number of wavelength midpoints

Public Static Functions

static std::string GetVersion()#

Get the version of TUV-x.

Returns:

TUV-x version string

namespace cuda#
class CudaRosenbrockSolver : public musica::IMicmSolver#
#include </home/docs/checkouts/readthedocs.org/user_builds/musica/checkouts/stable/src/cuda/cuda_solver.hpp>

CUDA Rosenbrock solver implementation.

Public Functions

virtual micm::SolverResult Solve(IState *state, double time_step) override#

Solve the chemical system for a given time step.

Parameters:
  • state – The state object containing concentrations and conditions

  • time_step – Time [s] to advance the state by

Returns:

Solver result containing status and statistics

virtual std::size_t MaximumNumberOfGridCells() const override#

Get the maximum number of grid cells this solver can handle.

Returns:

Maximum number of grid cells per state

virtual std::unique_ptr<IState> CreateState(std::size_t number_of_grid_cells) override#

Create a new state object compatible with this solver.

Parameters:

number_of_grid_cells – Number of grid cells for the state

Returns:

Unique pointer to a new IState implementation

virtual micm::System GetSystem() const override#

Get the chemical system configuration.

Returns:

The MICM System object

virtual std::unordered_map<std::string, std::size_t> GetSpeciesOrdering() const override#

Get the species ordering map.

Returns:

Map of species names to their indices

virtual std::unordered_map<std::string, std::size_t> GetRateParameterOrdering() const override#

Get the rate parameter ordering map.

Returns:

Map of rate parameter names to their indices

virtual std::size_t GetVectorSize() const override#

Get the vector size for this solver type.

Returns:

Vector dimension for vector-ordered solvers, 1 for standard-ordered solvers

class CudaState : public musica::IState#
#include </home/docs/checkouts/readthedocs.org/user_builds/musica/checkouts/stable/src/cuda/cuda_solver.hpp>

CUDA state implementation wrapping GpuState.

Public Functions

virtual std::size_t NumberOfGridCells() const override#

Get the number of grid cells.

Returns:

Number of grid cells

virtual std::size_t NumberOfSpecies() const override#

Get the number of species.

Returns:

Number of species

virtual std::size_t NumberOfUserDefinedRateParameters() const override#

Get the number of user-defined rate parameters.

Returns:

Number of user-defined rate parameters

virtual std::vector<micm::Conditions> &GetConditions() override#

Get the vector of conditions.

Returns:

Reference to vector of conditions

virtual const std::vector<micm::Conditions> &GetConditions() const override#

Get the vector of conditions (const version)

Returns:

Const reference to vector of conditions

virtual std::vector<double> &GetOrderedConcentrations() override#

Get the ordered concentrations vector.

Returns:

Reference to the concentrations vector

virtual const std::vector<double> &GetOrderedConcentrations() const override#

Get the ordered concentrations vector (const version)

Returns:

Const reference to the concentrations vector

virtual std::vector<double> &GetOrderedRateParameters() override#

Get the ordered rate parameters vector.

Returns:

Reference to the rate parameters vector

virtual const std::vector<double> &GetOrderedRateParameters() const override#

Get the ordered rate parameters vector (const version)

Returns:

Const reference to the rate parameters vector

virtual std::pair<std::size_t, std::size_t> GetConcentrationsStrides() const override#

Get the strides for the concentration matrix.

Returns:

Pair of (row_stride, column_stride)

virtual std::pair<std::size_t, std::size_t> GetRateParameterStrides() const override#

Get the strides for the rate parameter matrix.

Returns:

Pair of (row_stride, column_stride)

virtual std::unordered_map<std::string, std::size_t> GetVariableMap() const override#

Get the variable (species) ordering map.

Returns:

Map of species names to their indices

virtual std::unordered_map<std::string, std::size_t> GetRateParameterMap() const override#

Get the rate parameter ordering map.

Returns:

Map of rate parameter names to their indices

micm::GpuState &GetGpuState()#

Get access to the underlying GPU state for solving.