GeneralMath.h
1/* Distributed under the Apache License, Version 2.0.
2 See accompanying NOTICE file for details.*/
3
4#pragma once
5class SESubstance;
9
10class CDM_DECL GeneralMath
11{
12public:
13 static bool CalculateConcentration(const SEScalarMass& mass, const SEScalarVolume& volume, SEScalarMassPerVolume& concentration, Logger* logger = nullptr);
14 static bool CalculateMass(const SEScalarVolume& volume, const SEScalarMassPerVolume& concentration, SEScalarMass& mass, Logger* logger = nullptr);
15 static bool CalculateHenrysLawConcentration(const SESubstance& substance, const SEScalarPressure& partialPressure, SEScalarMassPerVolume& concentration, Logger* logger = nullptr);
16 static bool CalculatePartialPressureInGas(const SEScalar0To1& volumeFraction, const SEScalarPressure& pressure, SEScalarPressure& partialPressure, Logger* logger = nullptr);
17 static bool CalculatePartialPressureInLiquid(const SESubstance& substance, const SEScalarMassPerVolume& concentration, SEScalarPressure& partialPressure, Logger* logger = nullptr);
18 static void CalculateOsmolarity(const SEScalarAmountPerVolume& sodiumMolarity, const SEScalarAmountPerVolume& potassiumMolarity, const SEScalarAmountPerVolume& glucoseMolarity, const SEScalarAmountPerVolume& ureaMolarity, SEScalarOsmolarity& fluidOsmolarity);
19 static void CalculateOsmolality(const SEScalarAmountPerVolume& sodiumMolarity, const SEScalarAmountPerVolume& potassiumMolarity, const SEScalarAmountPerVolume& glucoseMolarity, const SEScalarAmountPerVolume& ureaMolarity, const SEScalar& specificGravity, SEScalarOsmolality& fluidOsmolality);
20 static bool CalculateSpecificGravity(const SEScalarMass& mass, const SEScalarVolume& volume, SEScalar& specificGravity, Logger* logger = nullptr);
21
22 static void Combinations(std::vector<size_t> maxValues, std::vector<std::vector<size_t>>& permutations);
23
24 static bool LinearInterpolator(std::vector<double>& v, size_t newSize);
25 static void LinearInterpolator1(std::vector<double>& v, size_t newSize);
26 static double LinearInterpolator(double initial, double target, double percent);
27 static double LinearInterpolator(double x1, double x2, double y1, double y2, double xPrime);
28 static double PiecewiseLinearInterpolator(const std::vector<std::pair<double, double>>& points, double x);
29 static void SplineInterpolater(std::vector<double>& v, size_t newSize);
30 static double ParbolicInterpolator(double min, double max, double factor);
31
32 static double Damper(double targetValue, double previousValue, double dampenFraction_perSec, double timeStep_s);
33
34 static double PercentDifference(double expected, double calculated);
35 static double PercentTolerance(double expected, double calculated, double epsilon = 1e-20);
36 static double ExponentialDecayFunction(double dbase, double dmin, double dmax, double dx);
37 static double ExponentialGrowthFunction(double dbase, double dmin, double dmax, double dx);
38 static double LogisticFunction(double a, double x50, double k, double x);
39 static double RootMeanSquaredError(std::vector<double> observed, std::vector<double> predicted, bool normalize = false, double outlierStandardDeviation = -1.0);
40};
Definition: GeneralMath.h:11
Definition: Logger.h:71
Definition: SELiquidCompartment.h:11
Definition: SELiquidSubstanceQuantity.h:12
Definition: SEScalar0To1.h:8
Definition: SEScalarAmountPerVolume.h:31
Definition: SEScalar.h:19
Definition: SEScalarMass.h:28
Definition: SEScalarMassPerVolume.h:37
Definition: SEScalarOsmolality.h:25
Definition: SEScalarOsmolarity.h:25
Definition: SEScalarPressure.h:29
Definition: SEScalarVolume.h:28
Definition: SESubstance.h:15
Definition: SESubstanceManager.h:9

Distributed under the Apache License, Version 2.0.

See accompanying NOTICE file for details.