public Substance(Pressure pressure, Enthalpy enthalpy) { Pressure = pressure; //Checking what region the Substanse belong to: //1. check if it is region 1 try { Temperature = new Temperature(Region1BackwardEquation_Tph.CalculateTemperature(pressure.Value, enthalpy.Value)); CalculateProperties(Temperature, Pressure); } catch (CantDetermineRegionException) { } if (SpecificEnthalpy!=null && Math.Round(SpecificEnthalpy.Value) == Math.Round(enthalpy.Value)) { //it is region 1 return; } //2. check if it is region 2 if (pressure.Value<=4) { Temperature = new Temperature(Region2aBackwardEquation_Tph.CalculateTemperature(pressure.Value, enthalpy.Value)); CalculateProperties(Temperature, Pressure); if (Math.Round(SpecificEnthalpy.Value, 1) == Math.Round(enthalpy.Value, 1)) { //it is region 2a return; } } else if (Region2B2bcEquation.is2cSubregion(pressure.Value, enthalpy.Value) == false) { Temperature = new Temperature(Region2bBackwardEquation_Tph.CalculateTemperature(pressure.Value, enthalpy.Value)); CalculateProperties(Temperature, Pressure); if (Math.Round(SpecificEnthalpy.Value, 1) == Math.Round(enthalpy.Value, 1)) { //it is region 2b return; } } else if (Region2B2bcEquation.is2cSubregion(pressure.Value, enthalpy.Value)) { Temperature = new Temperature(Region2cBackwardEquation_Tph.CalculateTemperature(pressure.Value, enthalpy.Value)); CalculateProperties(Temperature, Pressure); if (Math.Round(SpecificEnthalpy.Value, 1) == Math.Round(enthalpy.Value, 1)) { //it is region 2c return; } } else { throw new CantDetermineRegionException("It seems no region fits to these values pressure and enthalpy"); } }
private void Region5Calculations(Temperature temperature, Pressure pressure) { Temperature = temperature; Pressure = pressure; SpecificVolume = Region5.CalculateSpecificVolume(temperature.Value, pressure.Value); SpecificEnthalpy = new Enthalpy(Region5.CalculateSpecificEnthalpy(temperature.Value, pressure.Value)); SpecificInternalEnergy = Region5.CalculateSpecificInternalEnergy(temperature.Value, pressure.Value); SpecificEntropy = new Entropy(Region5.CalculateSpecificEntropy(temperature.Value, pressure.Value)); SpecificIsobaricHeatCapacity = Region5.SpecificIsobaricHeatCapacity(temperature.Value, pressure.Value); SpeedOfSound = Region5.SpeedOfSound(temperature.Value, pressure.Value); SpecificIsochoricHeatCapacity = Region5.SpecificIsochoricHeatCapacity(temperature.Value, pressure.Value); }