public static Blood Default() { var blood = new Blood { Water = 0, SmallWasteProducts = 0, BigWasteProducts = 0, HasHeparin = false, ChemicalCompositionOk = true, GasFree = false, Pressure = QualitativePressure.NoPressure, Temperature = QualitativeTemperature.TooCold }; return(blood); }
public void SetBloodFlow(Blood toSuccessor, Blood fromPredecessor) { if (fromPredecessor.Water > 0 || fromPredecessor.BigWasteProducts > 0) { toSuccessor.CopyValuesFrom(fromPredecessor); if (IncomingQuantityOfDialyzingFluid > 0) { toSuccessor.Temperature = IncomingFluidTemperature; //otherwise keep blood temperature } // First step: Filtrate Blood if (IncomingQuantityOfDialyzingFluid >= toSuccessor.SmallWasteProducts) { toSuccessor.SmallWasteProducts = 0; } else { toSuccessor.SmallWasteProducts -= IncomingQuantityOfDialyzingFluid; } // Second step: Ultra Filtration // To satisfy the incoming suction rate we must take the fluid from the blood. // The ultrafiltrationRate is the amount of fluid we take from the blood-side. var ultrafiltrationRate = IncomingSuctionRateOnDialyzingFluidSide - IncomingQuantityOfDialyzingFluid; if (ultrafiltrationRate >= 0) { if (ultrafiltrationRate < toSuccessor.BigWasteProducts) { toSuccessor.BigWasteProducts -= ultrafiltrationRate; } else { // Remove water instead of BigWasteProducts // Assume Water >= (ultrafiltrationRate - toSuccessor.BigWasteProducts) toSuccessor.Water -= (ultrafiltrationRate - toSuccessor.BigWasteProducts); toSuccessor.BigWasteProducts = 0; } } } else { toSuccessor.CopyValuesFrom(fromPredecessor); } if (!MembraneIntact) { toSuccessor.ChemicalCompositionOk = false; } }