projects/biogears/src/engine/Systems/Tissue.cpp
double Tissue::MoveMassByActiveTransport(SELiquidCompartment& source, SELiquidCompartment& target, const SESubstance& sub, double pumpRate_g_Per_s, double timestep_s)
{
  const SELiquidSubstanceQuantity* srcQ = source.GetSubstanceQuantity(sub);
  const SELiquidSubstanceQuantity* tgtQ = target.GetSubstanceQuantity(sub);

  double amountIncrement_g = pumpRate_g_Per_s * timestep_s;

  if (amountIncrement_g > 0.0) {
    if (amountIncrement_g > srcQ->GetMass(MassUnit::g)) {
      amountIncrement_g = srcQ->GetMass(MassUnit::g);
    }
    DistributeMassbyMassWeighted(source, sub, -amountIncrement_g, MassUnit::g);
    DistributeMassbyVolumeWeighted(target, sub, amountIncrement_g, MassUnit::g);
  } else // negative increment means it is coming from the target and going to the source
  {
    if (-amountIncrement_g > tgtQ->GetMass(MassUnit::g)) {
      amountIncrement_g = -tgtQ->GetMass(MassUnit::g);
    }
    DistributeMassbyVolumeWeighted(source, sub, -amountIncrement_g, MassUnit::g);
    DistributeMassbyMassWeighted(target, sub, amountIncrement_g, MassUnit::g);
  }

  // Note we are only changing mass and NOT balancing on purpose
  // We don't want the concentrations changing until we have completed our
  // diffusion methodology in its entirety

  return amountIncrement_g;
}
/// --------------------------------------------------------------------------------------------------
/// \brief
/// Calculates the mass transport of a substance between compartments by active transport
///
/// \param source: source compartment
/// \param target: target compartment
/// \param sub: substance that is diffusing
/// \param pumpRate_g_Per_s: the rate at which the pump is currently working
/// \param timestep_s: the time step
///
/// \details
/// This is a simplified pumping mechanism. This single mechanism lumps together all of the
/// biological mechanisms which "pump" a substance across a membrane against an electrochemical
/// or other gradient (all energy-requiring transport mechanisms). It computes a mass increment
/// based on a pump rate and then increments the mass. TThe method does not automatically update the concentration,
/// molarity, partial pressure, and other data in the compartment following the mass increment.
/// ***MUST CALL BALANCE TO UPDATE CONCENTRATION, MOLARITY, ETC.***
/// Note that the sign of the increment is determined by the source and target designation.
//--------------------------------------------------------------------------------------------------
\brief
Calculates the mass transport of a substance between compartments by active transport



\details
This is a simplified pumping mechanism. This single mechanism lumps together all of the
biological mechanisms which "pump" a substance across a membrane against an electrochemical
or other gradient (all energy-requiring transport mechanisms). It computes a mass increment
based on a pump rate and then increments the mass. TThe method does not automatically update the concentration,
molarity, partial pressure, and other data in the compartment following the mass increment.
MUST CALL BALANCE TO UPDATE CONCENTRATION, MOLARITY, ETC.
Note that the sign of the increment is determined by the source and target designation.
\ brief Calculates the mass transport of a substance between compartments by active transport \ details This is a simplified pumping mechanism . This single mechanism lumps together all of the biological mechanisms which " pump " a substance across a membrane against an electrochemical or other gradient ( all energy - requiring transport mechanisms ) . It computes a mass increment based on a pump rate and then increments the mass . TThe method does not automatically update the concentration molarity partial pressure and other data in the compartment following the mass increment . MUST CALL BALANCE TO UPDATE CONCENTRATION MOLARITY ETC . Note that the sign of the increment is determined by the source and target designation .
double Tissue::MoveMassByActiveTransport(SELiquidCompartment& source, SELiquidCompartment& target, const SESubstance& sub, double pumpRate_g_Per_s, double timestep_s)
{
  const SELiquidSubstanceQuantity* srcQ = source.GetSubstanceQuantity(sub);
  const SELiquidSubstanceQuantity* tgtQ = target.GetSubstanceQuantity(sub);
  double amountIncrement_g = pumpRate_g_Per_s * timestep_s;
  if (amountIncrement_g > 0.0) {
    if (amountIncrement_g > srcQ->GetMass(MassUnit::g)) {
      amountIncrement_g = srcQ->GetMass(MassUnit::g);
    }
    DistributeMassbyMassWeighted(source, sub, -amountIncrement_g, MassUnit::g);
    DistributeMassbyVolumeWeighted(target, sub, amountIncrement_g, MassUnit::g);
  } else 
  {
    if (-amountIncrement_g > tgtQ->GetMass(MassUnit::g)) {
      amountIncrement_g = -tgtQ->GetMass(MassUnit::g);
    }
    DistributeMassbyVolumeWeighted(source, sub, -amountIncrement_g, MassUnit::g);
    DistributeMassbyMassWeighted(target, sub, amountIncrement_g, MassUnit::g);
  }
  return amountIncrement_g;
}
double Tissue :: MoveMassByActiveTransport ( SELiquidCompartment & source , SELiquidCompartment & target , const SESubstance & sub , double pumpRate_g_Per_s , double timestep_s ) { const SELiquidSubstanceQuantity * srcQ = source . GetSubstanceQuantity ( sub ) ; const SELiquidSubstanceQuantity * tgtQ = target . GetSubstanceQuantity ( sub ) ; double amountIncrement_g = pumpRate_g_Per_s * timestep_s ; if ( amountIncrement_g > 0.0 ) { if ( amountIncrement_g > srcQ -> GetMass ( MassUnit :: g ) ) { amountIncrement_g = srcQ -> GetMass ( MassUnit :: g ) ; } DistributeMassbyMassWeighted ( source , sub , - amountIncrement_g , MassUnit :: g ) ; DistributeMassbyVolumeWeighted ( target , sub , amountIncrement_g , MassUnit :: g ) ; } else { if ( - amountIncrement_g > tgtQ -> GetMass ( MassUnit :: g ) ) { amountIncrement_g = - tgtQ -> GetMass ( MassUnit :: g ) ; } DistributeMassbyVolumeWeighted ( source , sub , - amountIncrement_g , MassUnit :: g ) ; DistributeMassbyMassWeighted ( target , sub , amountIncrement_g , MassUnit :: g ) ; } return amountIncrement_g ; }
\brief
Calculates the mass transport of a substance between compartments by active transport
\ brief Calculates the mass transport of a substance between compartments by active transport
// negative increment means it is coming from the target and going to the source // Note we are only changing mass and NOT balancing on purpose // We don't want the concentrations changing until we have completed our // diffusion methodology in its entirety