projects/biogears/src/engine/Systems/Nervous.cpp
void Nervous::ChemoreceptorFeedback()
{

  if (!m_FeedbackActive)
    return;

  double normalized_pO2 = m_data.GetBloodChemistry().GetArterialOxygenPressure(PressureUnit::mmHg) / m_ArterialOxygenSetPoint_mmHg;
  double normalized_pCO2 = m_data.GetBloodChemistry().GetArterialCarbonDioxidePressure(PressureUnit::mmHg) / m_ArterialCarbonDioxideSetPoint_mmHg;

  // The chemoreceptor heart rate modification function shape parameters.
  // See NervousMethodology documentation for details.
  double amax = -0.1;
  double a50 = 0.5;
  double aeta = -12.;
  double bmax = 1.;
  double b50 = 1.7;
  double beta = 18;
  double cmax = 1.;
  double c50 = 0.65;
  double ceta = -20;
  double dmax = -0.1;
  double d50 = b50;
  double deta = -aeta;

  //Calculate the normalized change in heart rate
  //double HRBaseline_per_min = m_HeartRateNoFeedbackBaseline_per_min;
  // Maximum HR delta is 1.23 times baseline. The derivation of this maximum is described in the NervousMethodology documentation
  //double maxHeartRateDelta = 1.23 * m_HeartRateNoFeedbackBaseline_per_min;
  double maxHeartRateDelta = 1.23 * m_data.GetPatient().GetHeartRateBaseline(FrequencyUnit::Per_min);
  double modifier = GeneralMath::LogisticFunction(amax, a50, aeta, normalized_pCO2);
  modifier += GeneralMath::LogisticFunction(bmax, b50, beta, normalized_pCO2);
  modifier += GeneralMath::LogisticFunction(cmax, c50, ceta, normalized_pO2);
  modifier += GeneralMath::LogisticFunction(dmax, d50, deta, normalized_pO2);

  //Apply central nervous depressant effects (currently only applies to morphine)
  SEDrugSystem& Drugs = m_data.GetDrugs();
  double CNSChange = Drugs.GetCentralNervousResponse().GetValue();
  if (CNSChange >= 0.25)
    modifier = 0.0;

  //set to zero if below .1 percent
  if (modifier < 0.001)
    modifier = 0.0;

  GetChemoreceptorHeartRateScale().SetValue(maxHeartRateDelta * modifier);

  // Calculate the normalized change in heart elastance
  double normalizedHeartElastance = 1.0;
  /// \todo Compute and apply chemoreceptor-mediated contractility changes
  GetChemoreceptorHeartElastanceScale().SetValue(normalizedHeartElastance);
}
//--------------------------------------------------------------------------------------------------
/// \brief
/// Calculates the chemoreceptor feedback and sets the scaling parameters in the CDM
///
/// \details
/// The chemoreceptor feedback function uses the current arterial partial pressure of oxygen and carbon dioxide
/// relative to the partial pressure set-points in order to calculate response signal.
/// The affected systems identify the signal and adjust accordingly. Note that chemoreception
/// is currently built into the respiratory driver; therefore, the chemoreceptor feedback only sets CV modifiers.
//--------------------------------------------------------------------------------------------------
\brief
Calculates the chemoreceptor feedback and sets the scaling parameters in the CDM

\details
The chemoreceptor feedback function uses the current arterial partial pressure of oxygen and carbon dioxide
relative to the partial pressure set-points in order to calculate response signal.
The affected systems identify the signal and adjust accordingly. Note that chemoreception
is currently built into the respiratory driver; therefore, the chemoreceptor feedback only sets CV modifiers.
\ brief Calculates the chemoreceptor feedback and sets the scaling parameters in the CDM \ details The chemoreceptor feedback function uses the current arterial partial pressure of oxygen and carbon dioxide relative to the partial pressure set - points in order to calculate response signal . The affected systems identify the signal and adjust accordingly . Note that chemoreception is currently built into the respiratory driver ; therefore the chemoreceptor feedback only sets CV modifiers .
void Nervous::ChemoreceptorFeedback()
{
  if (!m_FeedbackActive)
    return;
  double normalized_pO2 = m_data.GetBloodChemistry().GetArterialOxygenPressure(PressureUnit::mmHg) / m_ArterialOxygenSetPoint_mmHg;
  double normalized_pCO2 = m_data.GetBloodChemistry().GetArterialCarbonDioxidePressure(PressureUnit::mmHg) / m_ArterialCarbonDioxideSetPoint_mmHg;
  double amax = -0.1;
  double a50 = 0.5;
  double aeta = -12.;
  double bmax = 1.;
  double b50 = 1.7;
  double beta = 18;
  double cmax = 1.;
  double c50 = 0.65;
  double ceta = -20;
  double dmax = -0.1;
  double d50 = b50;
  double deta = -aeta;
  double maxHeartRateDelta = 1.23 * m_data.GetPatient().GetHeartRateBaseline(FrequencyUnit::Per_min);
  double modifier = GeneralMath::LogisticFunction(amax, a50, aeta, normalized_pCO2);
  modifier += GeneralMath::LogisticFunction(bmax, b50, beta, normalized_pCO2);
  modifier += GeneralMath::LogisticFunction(cmax, c50, ceta, normalized_pO2);
  modifier += GeneralMath::LogisticFunction(dmax, d50, deta, normalized_pO2);
  SEDrugSystem& Drugs = m_data.GetDrugs();
  double CNSChange = Drugs.GetCentralNervousResponse().GetValue();
  if (CNSChange >= 0.25)
    modifier = 0.0;
  if (modifier < 0.001)
    modifier = 0.0;
  GetChemoreceptorHeartRateScale().SetValue(maxHeartRateDelta * modifier);
  double normalizedHeartElastance = 1.0;
  GetChemoreceptorHeartElastanceScale().SetValue(normalizedHeartElastance);
}
void Nervous :: ChemoreceptorFeedback ( ) { if ( ! m_FeedbackActive ) return ; double normalized_pO2 = m_data . GetBloodChemistry ( ) . GetArterialOxygenPressure ( PressureUnit :: mmHg ) / m_ArterialOxygenSetPoint_mmHg ; double normalized_pCO2 = m_data . GetBloodChemistry ( ) . GetArterialCarbonDioxidePressure ( PressureUnit :: mmHg ) / m_ArterialCarbonDioxideSetPoint_mmHg ; double amax = -0.1 ; double a50 = 0.5 ; double aeta = -12. ; double bmax = 1. ; double b50 = 1.7 ; double beta = 18 ; double cmax = 1. ; double c50 = 0.65 ; double ceta = -20 ; double dmax = -0.1 ; double d50 = b50 ; double deta = - aeta ; double maxHeartRateDelta = 1.23 * m_data . GetPatient ( ) . GetHeartRateBaseline ( FrequencyUnit :: Per_min ) ; double modifier = GeneralMath :: LogisticFunction ( amax , a50 , aeta , normalized_pCO2 ) ; modifier += GeneralMath :: LogisticFunction ( bmax , b50 , beta , normalized_pCO2 ) ; modifier += GeneralMath :: LogisticFunction ( cmax , c50 , ceta , normalized_pO2 ) ; modifier += GeneralMath :: LogisticFunction ( dmax , d50 , deta , normalized_pO2 ) ; SEDrugSystem & Drugs = m_data . GetDrugs ( ) ; double CNSChange = Drugs . GetCentralNervousResponse ( ) . GetValue ( ) ; if ( CNSChange >= 0.25 ) modifier = 0.0 ; if ( modifier < 0.001 ) modifier = 0.0 ; GetChemoreceptorHeartRateScale ( ) . SetValue ( maxHeartRateDelta * modifier ) ; double normalizedHeartElastance = 1.0 ; GetChemoreceptorHeartElastanceScale ( ) . SetValue ( normalizedHeartElastance ) ; }
\brief
Calculates the chemoreceptor feedback and sets the scaling parameters in the CDM
\ brief Calculates the chemoreceptor feedback and sets the scaling parameters in the CDM
// The chemoreceptor heart rate modification function shape parameters. // See NervousMethodology documentation for details. //Calculate the normalized change in heart rate //double HRBaseline_per_min = m_HeartRateNoFeedbackBaseline_per_min; // Maximum HR delta is 1.23 times baseline. The derivation of this maximum is described in the NervousMethodology documentation //double maxHeartRateDelta = 1.23 * m_HeartRateNoFeedbackBaseline_per_min; //Apply central nervous depressant effects (currently only applies to morphine) //set to zero if below .1 percent // Calculate the normalized change in heart elastance /// \todo Compute and apply chemoreceptor-mediated contractility changes