Solvers and settings

Material-expression solvers, settings, and exceptions.

Note

MAT is experimental and unfinished; interfaces and behavior may change.

using snt::mat::ElementMap = std::map<std::string, int>

Map of elements in a substance and their proportions.

using snt::mat::SubstanceMap = std::map<std::string, double>

Map of substances in a material and their proportions.

constexpr std::string_view snt::mat::MAT_SYMBOL_PLUS
constexpr std::string_view snt::mat::MAT_SYMBOL_MULTIPLY
class Exception : public snt::core::Exception
#include <exceptions.h>

Subclassed by snt::mat::MissingException, snt::mat::ParserException, snt::mat::SyntaxException

Public Functions

inline explicit Exception(core::ExceptionInfo info)
inline explicit Exception(std::string message, std::string details, std::string suggestion, std::string origin_file, size_t origin_line)
class MaterialSolver
#include <material_solver.h>

This class solves material expressions

Public Functions

MaterialSolver()

Constructor of this class

class MissingException : public snt::mat::Exception
#include <exceptions.h>

Missing exception is triggered when functionality is not implemented yet

Public Functions

inline MissingException(std::string message, std::string file, std::size_t line)
class ParserException : public snt::mat::Exception
#include <exceptions.h>

Parser exceptions occurs when internal MAT parsers fails

class SubstanceAtom : public snt::exs::AtomBase<SubstanceAtom, ElementMap>
#include <substance_atom.h>

Substance expression solver

Public Functions

SubstanceAtom(const SubstanceAtom &a) = default

Copy constructor

Parameters:

a – Reference of an SubstanceAtom object

inline SubstanceAtom(ElementMap v)

Create atom from a value

Parameters:

v – ElementMap object

virtual std::string to_string() override

Get a string representation of this atom

Returns:

String representation of this atom

void math_add(SubstanceAtom *other) override

Add another value.

Parameters:

other – Other value used in the operation.

void math_multiply(SubstanceAtom *other) override

Public Static Functions

static ElementMap from_string(std::string s, exs::BaseSettings *set = nullptr)

Create atom value from a string

Parameters:
  • s – String representation of a value

  • set – Pointer to solver settings

Returns:

ElementMap object

class SubstanceSolver
#include <substance_solver.h>

This class solves substance expressions

Public Functions

SubstanceSolver() = default

Constructor of this class

std::string preprocess(const std::string &expr)

Preprocess expression for the solver

Parameters:

expr – Substance expression

ElementMap eval(const std::string &expr)

Solve expression using expression solver

Parameters:

expr – Substance expression

Returns:

Map of elements and their proportions

Public Static Attributes

static exs::Solver<SubstanceAtom> solver

Pointer to the EXS solver object.

class SyntaxException : public snt::mat::Exception
#include <exceptions.h>

Syntax exceptions are triggered by incorrect syntax

constexpr bool snt::mat::Config::debug_substance_solver

Show debugging printouts in substance solver.