Commit f4eb13f1 authored by Jeff Webb's avatar Jeff Webb
Browse files

Added damping to pleural cavity venous effects (mainly from pneumothorax) and...

Added damping to pleural cavity venous effects (mainly from pneumothorax) and tweaked bilateral pneumothorax scenario timing to prevent error from heavily diseased patient.
parent 58410cc4
......@@ -2144,9 +2144,20 @@ void Cardiovascular::CalculatePleuralCavityVenousEffects()
double resistanceMultiplier = a * factor * factor + min;
double rightHeartResistance_mmHg_s_Per_mL = m_RightHeartResistance->GetNextResistance(PressureTimePerVolumeUnit::mmHg_s_Per_mL);
m_RightHeartResistance->GetNextResistance().SetValue(rightHeartResistance_mmHg_s_Per_mL * resistanceMultiplier, PressureTimePerVolumeUnit::mmHg_s_Per_mL);
rightHeartResistance_mmHg_s_Per_mL *= resistanceMultiplier;
//Dampen the change to prevent potential craziness
//It will only change half as much as it wants to each time step to ensure it's critically damped and doesn't overshoot
double dampenFraction_perSec = 0.001 * 50.0;
double previousRightHeartResistance_mmHg_s_Per_mL = m_RightHeartResistance->GetResistance(PressureTimePerVolumeUnit::mmHg_s_Per_mL);
double resistanceChange_L_Per_mmHg_s_Per_mL = (rightHeartResistance_mmHg_s_Per_mL - previousRightHeartResistance_mmHg_s_Per_mL) * dampenFraction_perSec * m_dT_s;
rightHeartResistance_mmHg_s_Per_mL = previousRightHeartResistance_mmHg_s_Per_mL + resistanceChange_L_Per_mmHg_s_Per_mL;
m_RightHeartResistance->GetNextResistance().SetValue(rightHeartResistance_mmHg_s_Per_mL, PressureTimePerVolumeUnit::mmHg_s_Per_mL);
//For tuning
//m_data.GetDataTrack().Probe("pleuralCavityPressureDiff_cmH2O", pleuralCavityPressureDiff_cmH2O);
//m_data.GetDataTrack().Probe("resistanceMultiplier", resistanceMultiplier);
//m_data.GetDataTrack().Probe("rightHeartResistance_mmHg_s_Per_mL", rightHeartResistance_mmHg_s_Per_mL);
}
......@@ -1194,11 +1194,7 @@ void Respiratory::RespiratoryDriver()
m_NotBreathing = false;
}
if (m_VentilationFrequency_Per_min > dMaximumPulmonaryVentilationRate / dHalfVitalCapacity_L)
m_VentilationFrequency_Per_min = dMaximumPulmonaryVentilationRate / dHalfVitalCapacity_L;
if (m_VentilationFrequency_Per_min < 0.0)
m_VentilationFrequency_Per_min = 0.0;
m_VentilationFrequency_Per_min = LIMIT(m_VentilationFrequency_Per_min, 0.0, dMaximumPulmonaryVentilationRate / dHalfVitalCapacity_L);
//Patient Definition *************************************************************************
//We need to hit the patient's defined Respiration Rate Baseline, no matter what,
......@@ -2134,10 +2130,10 @@ void Respiratory::UpdateChestWallCompliances()
//Dampen the change to prevent potential craziness
//It will only change half as much as it wants to each time step to ensure it's critically damped and doesn't overshoot
double dampenFraction = 0.5;
double dampenFraction_perSec = 0.5 * 50.0;
double previousChestWallCompliance_L_Per_cmH2O = chestWallPath->GetCompliance(VolumePerPressureUnit::L_Per_cmH2O);
double complianceChange_L_Per_cmH2O = (chestWallCompliance_L_Per_cmH2O - previousChestWallCompliance_L_Per_cmH2O) * dampenFraction;
double complianceChange_L_Per_cmH2O = (chestWallCompliance_L_Per_cmH2O - previousChestWallCompliance_L_Per_cmH2O) * dampenFraction_perSec * m_dt_s;
chestWallCompliance_L_Per_cmH2O = previousChestWallCompliance_L_Per_cmH2O + complianceChange_L_Per_cmH2O;
chestWallPath->GetNextCompliance().SetValue(chestWallCompliance_L_Per_cmH2O, VolumePerPressureUnit::L_Per_cmH2O);
......
......@@ -150,7 +150,7 @@
"AdvanceTime": {
"Time": {
"ScalarTime": {
"Value": 30.0,
"Value": 20.0,
"Unit": "s"
}
}
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment