projects/biogears/src/engine/Controller/BioGearsSubstances.cpp
void BioGearsSubstances::CalculateGenericClearance(double volumeCleared_mL, SELiquidCompartment& cmpt, SESubstance& sub, SEScalarMass* cleared)
{
  SELiquidSubstanceQuantity* subQ = cmpt.GetSubstanceQuantity(sub);
  if (subQ == nullptr)
    throw CommonDataModelException("No Substance Quantity found for substance " + sub.GetName());
  //GetMass and Concentration from the compartment
  double mass_ug = subQ->GetMass(MassUnit::ug);
  double concentration_ug_Per_mL = subQ->GetConcentration(MassPerVolumeUnit::ug_Per_mL);

  //Calculate Mass Cleared
  double MassCleared_ug = volumeCleared_mL * concentration_ug_Per_mL;
  //Ensure mass does not become negative
  mass_ug -= MassCleared_ug;
  if (mass_ug < 0) {
    mass_ug = 0;
  }

  MassCleared_ug = subQ->GetMass(MassUnit::ug) - mass_ug;
  subQ->GetMass().SetValue(mass_ug, MassUnit::ug);
  subQ->Balance(BalanceLiquidBy::Mass);

  sub.GetSystemicMassCleared().IncrementValue(MassCleared_ug, MassUnit::ug);
  if (cleared != nullptr)
    cleared->SetValue(MassCleared_ug, MassUnit::ug);
}
/// --------------------------------------------------------------------------------------------------
/// \brief
/// Calculates the substance mass cleared for a node
///
/// \details
/// The volume cleared, the compartment, and the substance are provided to clear the mass of the substance
/// from the node. This generic methodology can be used by other systems to calculate the mass cleared.
//--------------------------------------------------------------------------------------------------
\brief
Calculates the substance mass cleared for a node

\details
The volume cleared, the compartment, and the substance are provided to clear the mass of the substance
from the node. This generic methodology can be used by other systems to calculate the mass cleared.
\ brief Calculates the substance mass cleared for a node \ details The volume cleared the compartment and the substance are provided to clear the mass of the substance from the node . This generic methodology can be used by other systems to calculate the mass cleared .
void BioGearsSubstances::CalculateGenericClearance(double volumeCleared_mL, SELiquidCompartment& cmpt, SESubstance& sub, SEScalarMass* cleared)
{
  SELiquidSubstanceQuantity* subQ = cmpt.GetSubstanceQuantity(sub);
  if (subQ == nullptr)
    throw CommonDataModelException("No Substance Quantity found for substance " + sub.GetName());
  double mass_ug = subQ->GetMass(MassUnit::ug);
  double concentration_ug_Per_mL = subQ->GetConcentration(MassPerVolumeUnit::ug_Per_mL);
  double MassCleared_ug = volumeCleared_mL * concentration_ug_Per_mL;
  mass_ug -= MassCleared_ug;
  if (mass_ug < 0) {
    mass_ug = 0;
  }
  MassCleared_ug = subQ->GetMass(MassUnit::ug) - mass_ug;
  subQ->GetMass().SetValue(mass_ug, MassUnit::ug);
  subQ->Balance(BalanceLiquidBy::Mass);
  sub.GetSystemicMassCleared().IncrementValue(MassCleared_ug, MassUnit::ug);
  if (cleared != nullptr)
    cleared->SetValue(MassCleared_ug, MassUnit::ug);
}
void BioGearsSubstances :: CalculateGenericClearance ( double volumeCleared_mL , SELiquidCompartment & cmpt , SESubstance & sub , SEScalarMass * cleared ) { SELiquidSubstanceQuantity * subQ = cmpt . GetSubstanceQuantity ( sub ) ; if ( subQ == nullptr ) throw CommonDataModelException ( " " + sub . GetName ( ) ) ; double mass_ug = subQ -> GetMass ( MassUnit :: ug ) ; double concentration_ug_Per_mL = subQ -> GetConcentration ( MassPerVolumeUnit :: ug_Per_mL ) ; double MassCleared_ug = volumeCleared_mL * concentration_ug_Per_mL ; mass_ug -= MassCleared_ug ; if ( mass_ug < 0 ) { mass_ug = 0 ; } MassCleared_ug = subQ -> GetMass ( MassUnit :: ug ) - mass_ug ; subQ -> GetMass ( ) . SetValue ( mass_ug , MassUnit :: ug ) ; subQ -> Balance ( BalanceLiquidBy :: Mass ) ; sub . GetSystemicMassCleared ( ) . IncrementValue ( MassCleared_ug , MassUnit :: ug ) ; if ( cleared != nullptr ) cleared -> SetValue ( MassCleared_ug , MassUnit :: ug ) ; }
\brief
Calculates the substance mass cleared for a node
\ brief Calculates the substance mass cleared for a node
//GetMass and Concentration from the compartment //Calculate Mass Cleared //Ensure mass does not become negative