Exemple #1
0
 public Gas(AtmosphericResourceManager rm)
 {
     Resource              = rm.managedResource;
     Quantity              = rm.getLevel();
     PartialPressure       = rm.Pressure;
     Temperature           = rm.Temperature;
     PartialEthalpy        = rm.EnthalpyPerUnitMass;
     PartialInternalEnergy = rm.InternalEnergy;
     Density = rm.Density;
 }
        public AirThermoState getAverageAirState()
        {
            double CO2, O, N, CH4, H2O, systemMass = getSystemMass();

            CO2 = co2ResourceManager.getLevel() / systemMass;
            O   = oResourceManager.getLevel() / systemMass;
            N   = nResourceManager.getLevel() / systemMass;
            CH4 = ch4ResourceManager.getLevel() / systemMass;
            H2O = h2oResourceManager.getLevel() / systemMass;

            double averageMolarWeight = getSystemAverageMolarWeight();

            double molarFractionCO2 = CO2 * (averageMolarWeight / co2ResourceManager.molarWeight);
            double molarFractionCH4 = CH4 * (averageMolarWeight / ch4ResourceManager.molarWeight);
            double molarFractionO   = O * (averageMolarWeight / oResourceManager.molarWeight);
            double molarFractionN   = N * (averageMolarWeight / nResourceManager.molarWeight);
            double molarFractionH2O = H2O * (averageMolarWeight / h2oResourceManager.molarWeight);

            var systemPressure = getSystemPressure();

            var weightedAverageSpecHeat = molarFractionCO2 * co2ResourceManager.SpecificHeat +
                                          molarFractionCH4 * ch4ResourceManager.SpecificHeat +
                                          molarFractionO * oResourceManager.SpecificHeat +
                                          molarFractionN * nResourceManager.SpecificHeat +
                                          molarFractionH2O * h2oResourceManager.SpecificHeat;

            var weightedAverageInternalEnergy = molarFractionCO2 * co2ResourceManager.InternalEnergy +
                                                molarFractionCH4 * ch4ResourceManager.InternalEnergy +
                                                molarFractionO * oResourceManager.InternalEnergy +
                                                molarFractionN * nResourceManager.InternalEnergy +
                                                molarFractionH2O * h2oResourceManager.InternalEnergy;

            var weightedAverageEnthalpy = molarFractionCO2 * co2ResourceManager.EnthalpyPerUnitMass +
                                          molarFractionCH4 * ch4ResourceManager.EnthalpyPerUnitMass +
                                          molarFractionO * oResourceManager.EnthalpyPerUnitMass +
                                          molarFractionN * nResourceManager.EnthalpyPerUnitMass +
                                          molarFractionH2O * h2oResourceManager.EnthalpyPerUnitMass;

            var weightedAverageCond = molarFractionCO2 * co2ResourceManager.ThermalConductivity +
                                      molarFractionCH4 * ch4ResourceManager.ThermalConductivity +
                                      molarFractionO * oResourceManager.ThermalConductivity +
                                      molarFractionN * nResourceManager.ThermalConductivity +
                                      molarFractionH2O * h2oResourceManager.ThermalConductivity;

            var weightedAverageVisc = molarFractionCO2 * co2ResourceManager.Viscosity +
                                      molarFractionCH4 * ch4ResourceManager.Viscosity +
                                      molarFractionO * oResourceManager.Viscosity +
                                      molarFractionN * nResourceManager.Viscosity +
                                      molarFractionH2O * h2oResourceManager.Viscosity;

            var weightedAverageDens = molarFractionCO2 * co2ResourceManager.Density +
                                      molarFractionCH4 * ch4ResourceManager.Density +
                                      molarFractionO * oResourceManager.Density +
                                      molarFractionN * nResourceManager.Density +
                                      molarFractionH2O * h2oResourceManager.Density;

            var weightedAverageTemp = molarFractionCO2 * co2ResourceManager.Temperature +
                                      molarFractionCH4 * ch4ResourceManager.Temperature +
                                      molarFractionO * oResourceManager.Temperature +
                                      molarFractionN * nResourceManager.Temperature +
                                      molarFractionH2O * h2oResourceManager.Temperature;

            double relativeHumidity = h2oResourceManager.Pressure / ArdenBuckEquation(h2oResourceManager.Temperature);

            return(new AirThermoState(weightedAverageTemp, systemPressure, weightedAverageEnthalpy, weightedAverageDens, weightedAverageInternalEnergy, weightedAverageCond, weightedAverageVisc, weightedAverageSpecHeat, relativeHumidity));
        }