Commit f0a8f2fc authored by Aaron Bray's avatar Aaron Bray
Browse files

CDM is working well, now for the Engine

parent e1ba1669
......@@ -2,9 +2,18 @@
See accompanying NOTICE file for details.*/
#include "stdafx.h"
#include "circuit/SECircuitManager.h"
#include "circuit/electrical/SEElectricalCircuit.h"
#include "circuit/fluid/SEFluidCircuit.h"
#include "circuit/fluid/SEFluidCircuitNode.h"
#include "circuit/fluid/SEFluidCircuitPath.h"
#include "circuit/thermal/SEThermalCircuit.h"
#include "circuit/thermal/SEThermalCircuitNode.h"
#include "circuit/thermal/SEThermalCircuitPath.h"
#include "circuit/electrical/SEElectricalCircuit.h"
#include "circuit/electrical/SEElectricalCircuitNode.h"
#include "circuit/electrical/SEElectricalCircuitPath.h"
#include <google/protobuf/text_format.h>
......
......@@ -4,6 +4,15 @@
#pragma once
CDM_BIND_DECL(CircuitNodeData)
#include "properties/SEScalarElectricCharge.h"
#include "properties/SEScalarElectricPotential.h"
#include "properties/SEScalarPressure.h"
#include "properties/SEScalarVolume.h"
#include "properties/SEScalarTemperature.h"
#include "properties/SEScalarEnergy.h"
#define CIRCUIT_NODE_TEMPLATE typename PotentialScalar, typename QuantityScalar
#define CIRCUIT_NODE_TYPES PotentialScalar,QuantityScalar
#define ELECTRICAL_CIRCUIT_NODE SEScalarElectricPotential, SEScalarElectricCharge
......
......@@ -4,6 +4,21 @@
#pragma once
#include "circuit/SECircuitNode.h"
#include "properties/SEScalarElectricCapacitance.h"
#include "properties/SEScalarElectricCurrent.h"
#include "properties/SEScalarElectricInductance.h"
#include "properties/SEScalarElectricResistance.h"
#include "properties/SEScalarFlowCompliance.h"
#include "properties/SEScalarVolumePerTime.h"
#include "properties/SEScalarFlowInertance.h"
#include "properties/SEScalarFlowResistance.h"
#include "properties/SEScalarHeatCapacitance.h"
#include "properties/SEScalarPower.h"
#include "properties/SEScalarHeatInductance.h"
#include "properties/SEScalarHeatResistance.h"
#define CIRCUIT_PATH_TEMPLATE typename FluxScalar, typename ResistanceScalar, typename CapacitanceScalar, typename InductanceScalar, typename PotentialScalar, typename QuantityScalar
#define CIRCUIT_PATH_TYPES FluxScalar,ResistanceScalar,CapacitanceScalar,InductanceScalar,PotentialScalar,QuantityScalar
#define ELECTRICAL_CIRCUIT_PATH SEScalarElectricCurrent, SEScalarElectricResistance, SEScalarElectricCapacitance, SEScalarElectricInductance, SEScalarElectricPotential, SEScalarElectricCharge
......
......@@ -6,13 +6,6 @@
#include "circuit/electrical/SEElectricalCircuitNode.h"
#include "circuit/electrical/SEElectricalCircuitPath.h"
#include "properties/SEScalarElectricCapacitance.h"
#include "properties/SEScalarElectricCurrent.h"
#include "properties/SEScalarElectricCharge.h"
#include "properties/SEScalarElectricInductance.h"
#include "properties/SEScalarElectricPotential.h"
#include "properties/SEScalarElectricResistance.h"
CDM_BIND_DECL(ElectricalCircuitData)
class SECircuitManager;
......
......@@ -5,12 +5,7 @@
#include "circuit/SECircuit.h"
#include "circuit/fluid/SEFluidCircuitNode.h"
#include "circuit/fluid/SEFluidCircuitPath.h"
#include "properties/SEScalarFlowCompliance.h"
#include "properties/SEScalarVolumePerTime.h"
#include "properties/SEScalarFlowInertance.h"
#include "properties/SEScalarPressure.h"
#include "properties/SEScalarVolume.h"
#include "properties/SEScalarFlowResistance.h"
CDM_BIND_DECL(FluidCircuitData)
class SECircuitManager;
......
......@@ -6,13 +6,6 @@
#include "circuit/thermal/SEThermalCircuitNode.h"
#include "circuit/thermal/SEThermalCircuitPath.h"
#include "properties/SEScalarHeatCapacitance.h"
#include "properties/SEScalarPower.h"
#include "properties/SEScalarHeatInductance.h"
#include "properties/SEScalarTemperature.h"
#include "properties/SEScalarEnergy.h"
#include "properties/SEScalarHeatResistance.h"
CDM_BIND_DECL(ThermalCircuitData)
class SECircuitManager;
......
......@@ -3,14 +3,26 @@
#include "stdafx.h"
#include "compartment/SECompartmentManager.h"
#include "circuit/SECircuitManager.h"
#include "compartment/fluid/SEGasCompartmentGraph.h"
#include "compartment/fluid/SELiquidCompartmentGraph.h"
#include "compartment/thermal/SEThermalCompartment.h"
#include "compartment/thermal/SEThermalCompartmentLink.h"
#include "compartment/tissue/SETissueCompartment.h"
// Circuits
#include "circuit/SECircuitManager.h"
#include "circuit/fluid/SEFluidCircuit.h"
#include "circuit/fluid/SEFluidCircuitNode.h"
#include "circuit/fluid/SEFluidCircuitPath.h"
#include "circuit/thermal/SEThermalCircuit.h"
#include "circuit/thermal/SEThermalCircuitNode.h"
#include "circuit/thermal/SEThermalCircuitPath.h"
#include "circuit/electrical/SEElectricalCircuit.h"
#include "circuit/electrical/SEElectricalCircuitNode.h"
#include "circuit/electrical/SEElectricalCircuitPath.h"
// Substances
#include "substance/SESubstance.h"
#include "substance/SESubstanceManager.h"
// Properties
#include "properties/SEScalarMassPerVolume.h"
#include "properties/SEScalarAmountPerVolume.h"
PROTO_PUSH
......
......@@ -4,6 +4,7 @@
#include "stdafx.h"
#include "compartment/fluid/SELiquidCompartment.h"
#include "compartment/substances/SELiquidSubstanceQuantity.h"
#include "substance/SESubstance.h"
#include "substance/SESubstanceManager.h"
#include "properties/SEScalar.h"
#include "properties/SEScalar0To1.h"
......
......@@ -3,6 +3,7 @@
#pragma once
#include "compartment/SECompartment.h"
#include "compartment/SECompartmentNodes.h"
#include "circuit/thermal/SEThermalCircuitNode.h"
CDM_BIND_DECL(ThermalCompartmentData);
class SEThermalCircuitNode;
class SEThermalCompartmentLink;
......
......@@ -15,6 +15,16 @@
#include "compartment/fluid/SELiquidCompartmentLink.h"
#include "compartment/thermal/SEThermalCompartment.h"
#include "compartment/tissue/SETissueCompartment.h"
// Circuit
#include "circuit/fluid/SEFluidCircuit.h"
#include "circuit/fluid/SEFluidCircuitNode.h"
#include "circuit/fluid/SEFluidCircuitPath.h"
#include "circuit/thermal/SEThermalCircuit.h"
#include "circuit/thermal/SEThermalCircuitNode.h"
#include "circuit/thermal/SEThermalCircuitPath.h"
#include "circuit/electrical/SEElectricalCircuit.h"
#include "circuit/electrical/SEElectricalCircuitNode.h"
#include "circuit/electrical/SEElectricalCircuitPath.h"
// Substances
#include "substance/SESubstance.h"
#include "substance/SESubstancePharmacokinetics.h"
......
......@@ -14,6 +14,7 @@
#include "compartment/fluid/SELiquidCompartment.h"
#include "compartment/fluid/SELiquidCompartmentLink.h"
#include "compartment/fluid/SELiquidCompartmentGraph.h"
#include "substance/SESubstance.h"
#include "compartment/substances/SELiquidSubstanceQuantity.h"
#include "properties/SEScalar0To1.h"
#include "properties/SEScalarMass.h"
......
......@@ -2,7 +2,9 @@
See accompanying NOTICE file for details.*/
#include "stdafx.h"
#include "Controller.h"
#include "Controller/Circuits.h"
#include "circuit/fluid/SEFluidCircuitNode.h"
#include "circuit/fluid/SEFluidCircuitPath.h"
PulseCircuits::PulseCircuits(PulseController& data) : SECircuitManager(data.GetLogger()), m_data(data)
{
......
......@@ -2,8 +2,11 @@
See accompanying NOTICE file for details.*/
#include "stdafx.h"
#include "Controller/Controller.h"
#include "Controller/Compartments.h"
#include "Controller/Substances.h"
#include "PulseConfiguration.h"
#include "substance/SESubstance.h"
#include "compartment/fluid/SEGasCompartment.h"
#include "compartment/fluid/SEGasCompartmentLink.h"
#include "compartment/fluid/SEGasCompartmentGraph.h"
......
......@@ -264,7 +264,7 @@ bool PulseController::SetupPatient()
double heightMin_cm = heightMinMale_cm;
double heightMax_cm = heightMaxMale_cm;
double heightStandard_cm = heightStandardMale_cm;
if (m_Patient->GetSex() == cdm::PatientData_eSex_Female)
if (m_Patient->GetSex() == cdm::ePatient_Sex_Female)
{
//Female
heightMin_cm = heightMinFemale_cm;
......@@ -351,7 +351,7 @@ bool PulseController::SetupPatient()
double fatFractionMin = fatFractionMinMale;
double fatFractionMax = fatFractionMaxMale;
double fatFractionStandard = fatFractionStandardMale;
if (m_Patient->GetSex() == cdm::PatientData_eSex_Female)
if (m_Patient->GetSex() == cdm::ePatient_Sex_Female)
{
//Female
fatFractionMin = fatFractionMinFemale;
......@@ -798,7 +798,7 @@ bool PulseController::SetupPatient()
/// \cite roza1984metabolic
double BMR_kcal_Per_day;
double computBMR_kcal_Per_day = 88.632 + 13.397 * weight_kg + 4.799 * height_cm - 5.677 * age_yr; //Male
if (m_Patient->GetSex() == cdm::PatientData_eSex_Female)
if (m_Patient->GetSex() == cdm::ePatient_Sex_Female)
{
computBMR_kcal_Per_day = 447.593 + 9.247 * weight_kg + 3.098 * height_cm - 4.330 * age_yr; //Female
}
......@@ -1009,7 +1009,7 @@ bool PulseController::CreateCircuitsAndCompartments()
void PulseController::SetupCardiovascular()
{
Info("Setting Up Cardiovascular");
bool male = m_Patient->GetSex() == cdm::PatientData_eSex_Male ? true : false;
bool male = m_Patient->GetSex() == cdm::ePatient_Sex_Male ? true : false;
double RightLungRatio = m_Patient->GetRightLungRatio().GetValue();
double LeftLungRatio = 1 - RightLungRatio;
double bloodVolume_mL = m_Patient->GetBloodVolumeBaseline(VolumeUnit::mL);
......@@ -2794,7 +2794,7 @@ void PulseController::SetupTissue()
//Typical ICRP Female - From ICRP
//Total Mass (kg)
if (m_Patient->GetSex() == cdm::PatientData_eSex_Female)
if (m_Patient->GetSex() == cdm::ePatient_Sex_Female)
{
AdiposeTissueMass = 19.0;
BoneTissueMass = 7.8;
......@@ -2820,7 +2820,7 @@ void PulseController::SetupTissue()
//Male
double standardPatientWeight_lb = 170.0;
double standardPatientHeight_in = 71.0;
if (m_Patient->GetSex() == cdm::PatientData_eSex_Female)
if (m_Patient->GetSex() == cdm::ePatient_Sex_Female)
{
//Female
standardPatientWeight_lb = 130.0;
......@@ -2833,14 +2833,14 @@ void PulseController::SetupTissue()
//Modify most based on lean body mass
//Hume, R (Jul 1966). "Prediction of lean body mass from height and weight." Journal of clinical pathology. 19 (4): 389�91. doi:10.1136/jcp.19.4.389. PMC 473290. PMID 5929341.
//double typicalLeanBodyMass_kg = 0.32810 * Convert(standardPatientWeight_lb, MassUnit::lb, MassUnit::kg) + 0.33929 * Convert(standardPatientHeight_in, LengthUnit::in, LengthUnit::cm) - 29.5336; //Male
//if (m_Patient->GetSex() == cdm::PatientData_eSex_Female)
//if (m_Patient->GetSex() == cdm::ePatient_Sex_Female)
//{
// typicalLeanBodyMass_kg = 0.29569 * Convert(standardPatientWeight_lb, MassUnit::lb, MassUnit::kg) + 0.41813 * Convert(standardPatientHeight_in, LengthUnit::in, LengthUnit::cm) - 43.2933; //Female
//}
//Male
double standardFatFraction = 0.21;
if (m_Patient->GetSex() == cdm::PatientData_eSex_Female)
if (m_Patient->GetSex() == cdm::ePatient_Sex_Female)
{
//Female
standardFatFraction = 0.28;
......
......@@ -2,38 +2,42 @@
See accompanying NOTICE file for details.*/
#pragma once
#include "PulseConfiguration.h"
#include "Controller/Circuits.h"
#include "Controller/Compartments.h"
#include "Controller/Substances.h"
#include "CommonDataModel.h"
PROTO_PUSH
#include "bind/engine/EngineEnums.pb.h"
PROTO_POP
class PulseConfiguration;
class PulseCircuits;
class PulseCompartments;
class PulseSubstances;
// CDM
#include "scenario/SEActionManager.h"
#include "scenario/SEConditionManager.h"
#include "properties/SEScalarTime.h"
class SEActionManager;
class SEConditionManager;
#include "utils/DataTrack.h"
#include "engine/SEEngineTracker.h"
class DataTrack;
class SEEngineTracker;
// Pulse
#include "Systems/BloodChemistry.h"
#include "Systems/Cardiovascular.h"
#include "Systems/Endocrine.h"
#include "Systems/Energy.h"
#include "Systems/Gastrointestinal.h"
#include "Systems/Hepatic.h"
#include "Systems/Nervous.h"
#include "Systems/Renal.h"
#include "Systems/Respiratory.h"
#include "Systems/Drugs.h"
#include "Systems/Tissue.h"
#include "Systems/Environment.h"
#include "Equipment/ECG.h"
#include "Equipment/AnesthesiaMachine.h"
#include "Equipment/Inhaler.h"
#include "Systems/Saturation.h"
class BloodChemistry;
class Cardiovascular;
class Endocrine;
class Energy;
class Gastrointestinal;
class Hepatic;
class Nervous;
class Renal;
class Respiratory;
class Drugs;
class Tissue;
class Environment;
class ECG;
class AnesthesiaMachine;
class Inhaler;
class SaturationCalculator;
class PulseScenarioExec;
enum class EngineState { NotReady=0, Initialization, InitialStabilization, AtInitialStableState, SecondaryStabilization, AtSecondaryStableState, Active };
......@@ -55,55 +59,55 @@ public:
virtual ~PulseController();
EngineState GetState() { return m_State; }
EngineState GetState();
DataTrack& GetDataTrack();
SaturationCalculator& GetSaturationCalculator() { return *m_SaturationCalculator; }
SaturationCalculator& GetSaturationCalculator();
PulseSubstances& GetSubstances() { return *m_Substances; }
PulseSubstances& GetSubstances();
SEPatient& GetPatient() { return *m_Patient; }
SEPatient& GetPatient();
bool GetPatientAssessment(SEPatientAssessment& assessment);
SEBloodChemistrySystem& GetBloodChemistry() { return *m_BloodChemistrySystem; }
SECardiovascularSystem& GetCardiovascular() { return *m_CardiovascularSystem; }
SEDrugSystem& GetDrugs() { return *m_DrugSystem; }
SEEndocrineSystem& GetEndocrine() { return *m_EndocrineSystem; }
SEEnergySystem& GetEnergy() { return *m_EnergySystem; }
SEGastrointestinalSystem& GetGastrointestinal() { return *m_GastrointestinalSystem; }
SEHepaticSystem& GetHepatic() { return *m_HepaticSystem; }
SENervousSystem& GetNervous() { return *m_NervousSystem; }
SERenalSystem& GetRenal() { return *m_RenalSystem; }
SERespiratorySystem& GetRespiratory() { return *m_RespiratorySystem; }
SETissueSystem& GetTissue() { return *m_TissueSystem; }
SEBloodChemistrySystem& GetBloodChemistry();
SECardiovascularSystem& GetCardiovascular();
SEDrugSystem& GetDrugs();
SEEndocrineSystem& GetEndocrine();
SEEnergySystem& GetEnergy();
SEGastrointestinalSystem& GetGastrointestinal();
SEHepaticSystem& GetHepatic();
SENervousSystem& GetNervous();
SERenalSystem& GetRenal();
SERespiratorySystem& GetRespiratory();
SETissueSystem& GetTissue();
SEEnvironment& GetEnvironment() { return *m_Environment; }
SEEnvironment& GetEnvironment();
SEAnesthesiaMachine& GetAnesthesiaMachine() { return *m_AnesthesiaMachine; }
SEAnesthesiaMachine& GetAnesthesiaMachine();
SEElectroCardioGram& GetECG() { return *m_ECG; }
SEElectroCardioGram& GetECG();
SEInhaler& GetInhaler() { return *m_Inhaler; }
SEInhaler& GetInhaler();
SEActionManager& GetActions() { return *m_Actions; }
SEActionManager& GetActions();
SEConditionManager& GetConditions() { return *m_Conditions; }
SEConditionManager& GetConditions();
PulseCircuits& GetCircuits() { return *m_Circuits; }
PulseCircuits& GetCircuits();
PulseCompartments& GetCompartments() { return *m_Compartments; }
PulseCompartments& GetCompartments();
const PulseConfiguration& GetConfiguration() { return *m_Config; }
const PulseConfiguration& GetConfiguration();
const SEScalarTime& GetEngineTime() { return *m_CurrentTime; }
const SEScalarTime& GetSimulationTime() { return *m_SimulationTime; }
const SEScalarTime& GetTimeStep() { return m_Config->GetTimeStep(); }
const SEScalarTime& GetEngineTime();
const SEScalarTime& GetSimulationTime();
const SEScalarTime& GetTimeStep();
pulse::eAirwayMode GetAirwayMode() { return m_AirwayMode; }
pulse::eAirwayMode GetAirwayMode();
void SetAirwayMode(pulse::eAirwayMode mode);
cdm::eSwitch GetIntubation() { return m_Intubation; }
cdm::eSwitch GetIntubation();
void SetIntubation(cdm::eSwitch s);
bool CreateCircuitsAndCompartments();
......
/* Distributed under the Apache License, Version 2.0.
See accompanying NOTICE file for details.*/
#include "stdafx.h"
#include "Controller/Engine.h"
PROTO_PUSH
#include "bind/engine/EngineState.pb.h"
PROTO_POP
#include "Controller/Engine.h"
#include "patient/SEPatient.h"
#include "circuit/SECircuit.h"
#include "circuit/SECircuitManager.h"
#include "compartment/SECompartmentManager.h"
#include "engine/SEEngineStabilization.h"
#include "scenario/SEScenario.h"
......@@ -469,7 +470,7 @@ void PulseEngine::AdvanceModelTime()
{
if (!IsReady())
return;
if(m_Patient->IsEventActive(cdm::PatientData_eEvent_IrreversibleState))
if(m_Patient->IsEventActive(cdm::ePatient_Event_IrreversibleState))
return;
PreProcess();
......
......@@ -2,18 +2,8 @@
See accompanying NOTICE file for details.*/
#pragma once
#pragma warning(push)
// Disabling the waring about STL classes used have
// to have a dll interface to be used by clients
// From what I have read STL is compiler dependent
// But since we are releasing source, you can build
// the project necessary to ensure proper linkage
// If anyone else has opinions on this, let us know
// kitware@kitware.com
#pragma warning(disable : 4251)
#include "Controller.h"
#pragma warning(pop)
#include "PhysiologyEngine.h"
#include "Controller/Controller.h"
//--------------------------------------------------------------------------------------------------
/// @brief
......@@ -79,6 +69,6 @@ protected:
virtual bool InitializeEngine(const std::vector<const SECondition*>* conditions = nullptr, const SEEngineConfiguration* config = nullptr);
SEEventHandler* m_EventHandler;
SEEngineTracker m_EngineTrack;
SEEngineTracker* m_EngineTrack;
std::stringstream m_ss;
};
\ No newline at end of file
......@@ -3,6 +3,7 @@
#include "stdafx.h"
#include "Controller/ScenarioExec.h"
#include "Controller/Engine.h"
#include "engine/SEAutoSerialization.h"
#include "PulseScenario.h"
#include "PulseConfiguration.h"
......
......@@ -2,8 +2,8 @@
See accompanying NOTICE file for details.*/
#pragma once
#include "Controller/Engine.h"
#include "scenario/SEScenarioExec.h"
class PulseEngine;
class PulseScenario;
/**
......
......@@ -2,9 +2,16 @@
See accompanying NOTICE file for details.*/
#include "stdafx.h"
#include "Controller/Substances.h"
#include "Controller/Compartments.h"
#include "Controller/Controller.h"
#include "Systems/Saturation.h"
#include "patient/SEPatient.h"
#include "substance/SESubstance.h"
#include "substance/SESubstanceAerosolization.h"
#include "substance/SESubstancePharmacodynamics.h"
#include "system/environment/SEEnvironment.h"
#include "Substances.h"
#include "Controller.h"
#include "compartment/fluid/SEGasCompartment.h"
#include "compartment/fluid/SEGasCompartmentLink.h"
#include "compartment/substances/SEGasSubstanceQuantity.h"
......@@ -14,9 +21,11 @@
#include "compartment/tissue/SETissueCompartment.h"
#include "properties/SEScalar0To1.h"
#include "properties/SEScalarAmountPerVolume.h"
#include "properties/SEScalarMass.h"
#include "properties/SEScalarMassPerVolume.h"
#include "properties/SEScalarMassPerAmount.h"
#include "properties/SEHistogramFractionVsLength.h"
#include "utils/DataTrack.h"
PulseSubstances::PulseSubstances(PulseController& data) : SESubstanceManager(data.GetLogger()), m_data(data)
{
......@@ -182,7 +191,7 @@ void PulseSubstances::InitializeLiquidCompartmentGases()
SEScalarAmountPerVolume phosphate;
albuminConcentration.SetValue(45.0, MassPerVolumeUnit::g_Per_L);
hematocrit.SetValue(m_data.GetPatient().GetSex() == cdm::PatientData_eSex_Male ? 0.45 : 0.40);
hematocrit.SetValue(m_data.GetPatient().GetSex() == cdm::ePatient_Sex_Male ? 0.45 : 0.40);
bodyTemp.SetValue(37.0, TemperatureUnit::C);
strongIonDifference.SetValue(40.5, AmountPerVolumeUnit::mmol_Per_L);
phosphate.SetValue(1.1, AmountPerVolumeUnit::mmol_Per_L);
......@@ -814,7 +823,7 @@ void PulseSubstances::AddActiveSubstance(SESubstance& substance)
return;// If its already active, don't do anything
SESubstanceManager::AddActiveSubstance(substance);
if (substance.GetState() == cdm::SubstanceData_eState_Gas)
if (substance.GetState() == cdm::eSubstance_State_Gas)
m_data.GetCompartments().AddGasCompartmentSubstance(substance);
m_data.GetCompartments().AddLiquidCompartmentSubstance(substance);
......
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