Exemplo n.º 1
0
        private IList <Substance> GetGenericFuelSubstanceList()
        {
            SubstanceCatalog  sc            = SubstanceCatalog.GetInstance();
            IList <Substance> substanceList = new List <Substance>();

            substanceList.Add(sc.GetSubstance(Substance.CARBON));
            substanceList.Add(sc.GetSubstance(Substance.HYDROGEN));
            substanceList.Add(sc.GetSubstance(Substance.OXYGEN));
            substanceList.Add(sc.GetSubstance(Substance.SULFUR));

            return(substanceList);
        }
Exemplo n.º 2
0
        private IList <Substance> GetGenericFuelSubstanceList()
        {
            SubstanceCatalog  sc            = SubstanceCatalog.GetInstance();
            IList <Substance> substanceList = new List <Substance>();

            substanceList.Add(sc.GetSubstance("carbon"));
            substanceList.Add(sc.GetSubstance("hydrogen"));
            substanceList.Add(sc.GetSubstance("oxygen"));
            substanceList.Add(sc.GetSubstance("sulfer"));

            return(substanceList);
        }
Exemplo n.º 3
0
        private FossilFuel GetDefaultFossilFuel()
        {
            SubstanceCatalog catalog         = SubstanceCatalog.GetInstance();
            Substance        methan          = catalog.GetSubstance(Substance.METHANE);
            Substance        ethane          = catalog.GetSubstance(Substance.ETHANE);
            Substance        propane         = catalog.GetSubstance(Substance.PROPANE);
            Substance        butane          = catalog.GetSubstance(Substance.BUTANE);
            Substance        carbonDioxide   = catalog.GetSubstance(Substance.CARBON_DIOXIDE);
            Substance        oxygen          = catalog.GetSubstance(Substance.OXYGEN);
            Substance        nitrogen        = catalog.GetSubstance(Substance.NITROGEN);
            Substance        hydrogenSulfide = catalog.GetSubstance(Substance.HYDROGEN_SULFIDE);

            ArrayList compList = new ArrayList();

            //compList.Add(new MaterialComponent(methan, 1.0));
            compList.Add(new MaterialComponent(methan, 0.8));
            compList.Add(new MaterialComponent(ethane, 0.108));
            compList.Add(new MaterialComponent(propane, 0.02));
            compList.Add(new MaterialComponent(butane, 0.016));
            compList.Add(new MaterialComponent(carbonDioxide, 0.04));
            compList.Add(new MaterialComponent(oxygen, 0.002));
            compList.Add(new MaterialComponent(nitrogen, 0.025));
            compList.Add(new MaterialComponent(hydrogenSulfide, 0.025));

            return(new FossilFuel(FossilFuel.NATURAL_GAS, compList, FossilFuelType.Detailed, false));
        }
Exemplo n.º 4
0
        //public DryingGasCatalog(IList list) {
        //   gasList = list;
        //}

        private void InitializeCatalog()
        {
            //SubstanceLibraryService sls = SubstanceLibraryService.GetInstance();
            SubstanceCatalog sc = SubstanceCatalog.GetInstance();

            DryingGas dgAir = new DryingGas("Air", sc.GetSubstance("air"), false);

            gasList.Add(dgAir);
            //gasMoistureSubstanceListTable.Add(dgAir, sc.GetMoistureSubstanceListForAir());

            DryingGas dgNitrogen = new DryingGas("Nitrogen", sc.GetSubstance("nitrogen"), false);

            gasList.Add(dgNitrogen);

            //gasMoistureSubstanceListTable.Add(dgNitrogen, sc.GetMoistureSubstanceListForNitrogen());
        }
Exemplo n.º 5
0
        //public DryingMaterialComponentsCacheModel(string name, MaterialType materialType, ArrayList materialComponentList, Substance moistureSubstance) : base (name, materialComponentList) {
        //   this.moistureSubstance = moistureSubstance;
        //}

        public void SetMaterialType(MaterialType type)
        {
            if (type == materialType)
            {
                return;
            }

            MaterialType oldValue = materialType;

            if (type == MaterialType.GenericMaterial)
            {
                RemoveAllMaterialComponents();
                SubstanceCatalog sc = SubstanceCatalog.GetInstance();
                Substance        absoluteDryMaterial = sc.GetSubstance("Dry Material");
                materialComponentList.Add(new MaterialComponent(absoluteDryMaterial));
            }
            else if (type == MaterialType.GenericFood)
            {
                SwitchToGenericFood();
            }
            //else if (materialType == MaterialType.GenericFood) {
            //   SwitchFromGenericFood();
            //}

            materialType = type;
            OnMaterialTypeChanged(materialType, oldValue);
        }
Exemplo n.º 6
0
        private void InitializeCatalog()
        {
            //SubstanceLibraryService sls = SubstanceLibraryService.GetInstance();
            SubstanceCatalog sc = SubstanceCatalog.GetInstance();
            DryingGas        dg = new DryingGas("Air", sc.GetSubstance("Air"), false);

            gasList.Add(dg);
        }
Exemplo n.º 7
0
        private void InitializeCatalog()
        {
            SubstanceCatalog sc = SubstanceCatalog.GetInstance();
            Substance        absoluteDryMaterial = sc.GetSubstance("Dry Material");
            Substance        moisture            = sc.GetSubstance("Water");
            ArrayList        dryMatComponents    = new ArrayList();

            dryMatComponents.Add(new MaterialComponent(absoluteDryMaterial));
            CompositeSubstance dryMat = new CompositeSubstance("Generic Dry Material", dryMatComponents);
            DryingMaterial     dm     = new DryingMaterial("Generic Material", MaterialType.GenericMaterial, dryMat, moisture, false);
            //materialList.Add(dm);
            DryingMaterial milk = (DryingMaterial)dm.Clone();

            milk.Name         = "Milk";
            milk.MaterialType = MaterialType.SpecialFood;
            //materialList.Add(milk);
        }
Exemplo n.º 8
0
        private void buttonSubstanceDetails_Click(object sender, System.EventArgs e)
        {
            ListViewItem lvi = (ListViewItem)this.substancesControl.ListViewSubstances.SelectedItems[0];

            ListViewItem.ListViewSubItem lvsi = (ListViewItem.ListViewSubItem)lvi.SubItems[0];
            Substance            substance    = SubstanceCatalog.GetSubstance(lvsi.Text);
            SubstanceDetailsForm form         = new SubstanceDetailsForm(substance);

            form.ShowDialog();
        }
Exemplo n.º 9
0
        public Substance GetSelectedSubstance()
        {
            Substance subst = null;

            if (this.listViewSubstances.SelectedItems.Count > 0)
            {
                ListViewItem lvi = (ListViewItem)this.listViewSubstances.SelectedItems[0];
                ListViewItem.ListViewSubItem lvsi = (ListViewItem.ListViewSubItem)lvi.SubItems[0];
                subst = SubstanceCatalog.GetSubstance(lvsi.Text);
            }
            return(subst);
        }
Exemplo n.º 10
0
        public DryingMaterialCache(DryingMaterialCatalog catalog)
            : base()
        {
            this.materialType = MaterialType.GenericMaterial;
            this.catalog      = catalog;
            //cacheType = CacheType.New;
            SubstanceCatalog sc = SubstanceCatalog.GetInstance();
            Substance        absoluteDryMaterial = sc.GetSubstance("Dry Material");

            materialComponentList.Add(new MaterialComponent(absoluteDryMaterial));
            specificHeatOfAbsoluteDryMaterial = new ProcessVarDouble(StringConstants.SPECIFIC_HEAT_ABS_DRY, PhysicalQuantity.SpecificHeat, 1260.0, VarState.Specified, this);
        }
Exemplo n.º 11
0
        public override void SetObjectData()
        {
            base.SetObjectData();
            int persistedClassVersion = (int)info.GetValue("ClassPersistenceVersionDryingGas", typeof(int));

            if (persistedClassVersion == 1)
            {
                this.name          = (string)info.GetValue("Name", typeof(string));
                this.isUserDefined = (bool)info.GetValue("IsUserDefined", typeof(bool));
                string substanceName = info.GetValue("SubstanceName", typeof(string)) as string;
                this.substance = SubstanceCatalog.GetSubstance(substanceName);
            }
        }
Exemplo n.º 12
0
        private ArrayList RecallSubstanceList(string name)
        {
            ArrayList        nameList      = RecallArrayListObject(name);
            ArrayList        substanceList = new ArrayList();
            SubstanceCatalog sc            = SubstanceCatalog.GetInstance();

            foreach (string substanceName in nameList)
            {
                substanceList.Add(SubstanceCatalog.GetSubstance(substanceName));
            }

            return(substanceList);
        }
Exemplo n.º 13
0
        public ArrayList GetSelectedSubstances()
        {
            ArrayList   list = new ArrayList();
            IEnumerator en   = this.listViewSubstances.SelectedItems.GetEnumerator();

            while (en.MoveNext())
            {
                ListViewItem lvi = (ListViewItem)en.Current;
                ListViewItem.ListViewSubItem lvsi = (ListViewItem.ListViewSubItem)lvi.SubItems[0];
                Substance subst = SubstanceCatalog.GetSubstance(lvsi.Text);
                list.Add(subst);
            }
            return(list);
        }
Exemplo n.º 14
0
        private void SwitchToGenericFood()
        {
            RemoveAllMaterialComponents();

            SubstanceCatalog substanceCatalog = SubstanceCatalog.GetInstance();

            IList genericFoodSubstanceList = substanceCatalog.GetGenericFoodSubstanceList();

            foreach (Substance s in genericFoodSubstanceList)
            {
                materialComponentList.Add(new MaterialComponent(s));
            }

            OnMaterialComponentsChanged();
            MoistureSubstance = substanceCatalog.GetSubstance("water");
        }
Exemplo n.º 15
0
        private void SwitchToGenericFood()
        {
            RemoveAllMaterialComponents();

            SubstanceCatalog substanceCatalog = SubstanceCatalog.GetInstance();

            materialComponentList.Add(new MaterialComponent(substanceCatalog.GetSubstance("Carbohydrate")));
            materialComponentList.Add(new MaterialComponent(substanceCatalog.GetSubstance("Ash")));
            materialComponentList.Add(new MaterialComponent(substanceCatalog.GetSubstance("Fiber")));
            materialComponentList.Add(new MaterialComponent(substanceCatalog.GetSubstance("Fat")));
            materialComponentList.Add(new MaterialComponent(substanceCatalog.GetSubstance("Protein")));
            OnMaterialComponentsChanged();
            MoistureSubstance = substanceCatalog.GetSubstance("Water");
        }
Exemplo n.º 16
0
        //public DryingMaterialCatalog(IList list) {
        //   materialList = list;
        //}

        private void InitializeCatalog()
        {
            SubstanceCatalog sc = SubstanceCatalog.GetInstance();
            //Substance absoluteDryMaterial = sc.GetSubstance("Dry Material");
            Substance absoluteDryMaterial = sc.GetGenericSubstance();
            Substance moisture            = sc.GetSubstance(Substance.WATER);
            ArrayList dryMatComponents    = new ArrayList();

            dryMatComponents.Add(new MaterialComponent(absoluteDryMaterial));
            CompositeSubstance dryMat = new CompositeSubstance("Generic Dry Material", dryMatComponents);

            if (!IsInCatalog(DryingMaterial.GENERIC_DRYING_MATERIAL))
            {
                DryingMaterial dm = new DryingMaterial(DryingMaterial.GENERIC_DRYING_MATERIAL, MaterialType.GenericMaterial, dryMat, moisture, false);
                materialList.Add(dm);
            }

            //DryingMaterial milk = (DryingMaterial)dm.Clone();
            //milk.Name = "Milk";
            //milk.MaterialType = MaterialType.SpecialFood;
            //materialList.Add(milk);
        }
Exemplo n.º 17
0
        private IList GetFuelSubstanceList()
        {
            SubstanceCatalog substanceCatalog        = SubstanceCatalog.GetInstance();
            IList            naturalGasSubstancelist = substanceCatalog.GetNaturalGasSubstanceList();
            IList            list = new ArrayList(naturalGasSubstancelist);

            IList allSubstanceList   = substanceCatalog.GetSubstanceList();
            IList perrySubstanceList = ThermalPropCalculator.Instance.GetPerrySubstanceNameList();

            foreach (Substance s in allSubstanceList)
            {
                if (perrySubstanceList.Contains(s.Name))
                {
                    if (s.Formula.Elements.Length == 2 && s.Formula.Elements[0] == "C" && s.Formula.Elements[1] == "H" && !list.Contains(s))
                    {
                        list.Add(s);
                    }
                }
            }

            list.Add(substanceCatalog.GetSubstance(Substance.ETHANOL));

            return(list);
        }
Exemplo n.º 18
0
        private void Solve()
        {
            SubstanceCatalog catalog       = SubstanceCatalog.GetInstance();
            Substance        carbon        = catalog.GetSubstance("carbon");
            Substance        hydrogen      = catalog.GetSubstance("hydrogen");
            Substance        oxygen        = catalog.GetSubstance("oxygen");
            Substance        sulfur        = catalog.GetSubstance("sulfur");
            Substance        air           = catalog.GetSubstance("air");
            Substance        carbonDioxide = catalog.GetSubstance("carbon dioxide");
            Substance        sulfurDioxide = catalog.GetSubstance("sulfur dioxide");
            Substance        water         = catalog.GetSubstance("water");
            Substance        nitrogen      = catalog.GetSubstance("nitrogen");
            Substance        argon         = catalog.GetSubstance("argon");
            //Substance ash = SubstanceCatalog.GetInstance().GetSubstance("ash");

            double totalEenthalpyOfReactantInFuelInlet = 0;
            double moleFractionCarbon   = 0;
            double moleFractionHydrogen = 0;
            double moleFractionSulfur   = 0;
            double moleFractionOxygen   = 0;
            //double massAsh = 0;
            double             moleFractionCarbonDioxide = 0;
            double             moleFractionNitrogen      = 0;
            MaterialComponents components = fuelInlet.Components;
            MaterialComponent  component;
            Substance          mySubstance;
            double             myMassFraction;

            if (fuelInlet is GenericFuelStream)
            {
                for (int i = 0; i < components.Count; i++)
                {
                    component      = components[i];
                    mySubstance    = component.Substance;
                    myMassFraction = component.MassFraction.Value;
                    if (mySubstance == carbon)
                    {
                        moleFractionCarbon = myMassFraction / carbon.MolarWeight;
                    }
                    else if (mySubstance == hydrogen)
                    {
                        moleFractionHydrogen = 0.5 * myMassFraction / hydrogen.MolarWeight;
                    }
                    else if (mySubstance == oxygen)
                    {
                        moleFractionOxygen = myMassFraction / oxygen.MolarWeight;
                    }
                    else if (mySubstance == sulfur)
                    {
                        moleFractionSulfur = myMassFraction / sulfur.MolarWeight;
                    }
                    //else if (component.Substance == ash) {
                    //   massAsh = myMassFraction;
                    //}
                }
            }
            else if (fuelInlet is DetailedFuelStream)
            {
                totalEenthalpyOfReactantInFuelInlet = 0;
                moleFractionCarbon   = 0;
                moleFractionHydrogen = 0;
                moleFractionOxygen   = 0;
                moleFractionSulfur   = 0;
                SubstanceFormula formula;
                string[]         elements;
                int    elementCount;
                double t = fuelInlet.Temperature.Value;
                for (int i = 0; i < components.Count; i++)
                {
                    component      = components[i];
                    mySubstance    = component.Substance;
                    myMassFraction = component.MassFraction.Value;

                    if (mySubstance == carbonDioxide)
                    {
                        moleFractionCarbonDioxide = myMassFraction / carbonDioxide.MolarWeight;
                    }
                    else if (mySubstance == nitrogen)
                    {
                        moleFractionNitrogen = myMassFraction / nitrogen.MolarWeight;
                    }
                    else
                    {
                        totalEenthalpyOfReactantInFuelInlet += myMassFraction * ThermalPropCalculator.Instance.CalculateEnthalpyOfFormation(t, mySubstance);
                        formula  = mySubstance.Formula;
                        elements = formula.Elements;
                        foreach (string element in elements)
                        {
                            elementCount = formula.GetElementCount(element);
                            if (element == "C")
                            {
                                moleFractionCarbon += elementCount * myMassFraction / carbon.MolarWeight;
                            }
                            else if (element == "H")
                            {
                                moleFractionHydrogen += elementCount * 0.25 * myMassFraction / hydrogen.MolarWeight;
                            }
                            else if (element == "O")
                            {
                                moleFractionOxygen = elementCount * 0.5 * myMassFraction / oxygen.MolarWeight;
                            }
                            else if (element == "S")
                            {
                                moleFractionSulfur += elementCount * myMassFraction / sulfur.MolarWeight;
                            }
                        }
                    }
                }
            }

            double fuelMassFlowRate                   = fuelInlet.MassFlowRate.Value;
            double moleFractionOxygenNeeded           = moleFractionCarbon + moleFractionHydrogen + moleFractionSulfur - moleFractionOxygen;
            double totalExactOxygenMassNeeded         = fuelMassFlowRate * moleFractionOxygenNeeded * oxygen.MolarWeight;
            double totalOxygenMoleNeeded              = fuelMassFlowRate * moleFractionOxygenNeeded * (1.0 + excessAir.Value);
            double totalDryAirMassNeeded              = totalOxygenMoleNeeded * air.MolarWeight / 0.21;
            double totalMoistureMassCarriedByInletAir = totalDryAirMassNeeded * airInlet.Humidity.Value;
            double totalAirMassNeeded                 = totalDryAirMassNeeded + totalMoistureMassCarriedByInletAir;

            Calculate(airInlet.MassFlowRate, totalAirMassNeeded);

            double totalMoitureGeneratedByReaction = fuelMassFlowRate * moleFractionHydrogen * water.MolarWeight;
            double totalMoistureInFlueGas          = totalMoitureGeneratedByReaction + totalMoistureMassCarriedByInletAir;

            double totalDryFlueGas       = totalDryAirMassNeeded + fuelMassFlowRate - totalMoitureGeneratedByReaction;
            double totalFlueGasGenerated = totalDryFlueGas + totalMoistureInFlueGas;

            Calculate(flueGasOutlet.MassFlowRate, totalFlueGasGenerated);

            double flueGasMoistureContentDryBase = totalMoistureInFlueGas / totalDryFlueGas;

            Calculate(flueGasOutlet.Humidity, flueGasMoistureContentDryBase);

            ArrayList componentList             = new ArrayList();
            double    massFractionCarbonDioxide = fuelMassFlowRate * (moleFractionCarbon + moleFractionCarbonDioxide) * carbonDioxide.MolarWeight / totalDryFlueGas;

            componentList.Add(new MaterialComponent(carbonDioxide, massFractionCarbonDioxide));

            double massFractionNitrogen = (totalDryAirMassNeeded * 0.78 + fuelMassFlowRate * moleFractionNitrogen) / totalDryFlueGas;

            componentList.Add(new MaterialComponent(nitrogen, massFractionNitrogen));

            double massFractionSulfurDioxide = fuelMassFlowRate * moleFractionSulfur * sulfurDioxide.MolarWeight / totalDryFlueGas;

            componentList.Add(new MaterialComponent(sulfurDioxide, massFractionSulfurDioxide));

            double massFractionOxygen = fuelMassFlowRate * moleFractionOxygenNeeded * excessAir.Value * oxygen.MolarWeight / totalDryFlueGas;

            componentList.Add(new MaterialComponent(oxygen, massFractionOxygen));

            double massFractionArgon = totalDryAirMassNeeded * 0.01 / totalDryFlueGas;

            componentList.Add(new MaterialComponent(argon, massFractionArgon));

            CompositeSubstance flueGas = new CompositeSubstance("Flue Gas", componentList);

            MaterialComponents flueGasComponents = new MaterialComponents();

            flueGasComponents.Add(new MaterialComponent(flueGas, 1 / (1 + flueGasMoistureContentDryBase)));
            flueGasComponents.Add(new MaterialComponent(water, flueGasMoistureContentDryBase / (1 + flueGasMoistureContentDryBase)));

            flueGasOutlet.Components = flueGasComponents;

            double fuelInletEnthalpy  = fuelMassFlowRate * fuelInlet.SpecificEnthalpy.Value;
            double airInletEnthalpy   = totalAirMassNeeded * airInlet.SpecificEnthalpy.Value;
            double totalHeatGenerated = Constants.NO_VALUE;

            if (fuelInlet is GenericFuelStream)
            {
                GenericFuelStream gfs = fuelInlet as GenericFuelStream;
                if (gfs.HeatValue.HasValue)
                {
                    //total heat genrate eaquls to heat value of the fuel times fuelMassFlowRate
                    totalHeatGenerated = gfs.HeatValue.Value * fuelMassFlowRate;
                    double totalFlueGasSpecificEnthalpy = (fuelInletEnthalpy + airInletEnthalpy + totalHeatGenerated) / totalFlueGasGenerated;
                    Calculate(flueGasOutlet.SpecificEnthalpy, totalFlueGasSpecificEnthalpy);
                }
            }
            else if (fuelInlet is DetailedFuelStream)
            {
                HumidGasCalculator    humidGasCalculator = new HumidGasCalculator(flueGas, water);
                ThermalPropCalculator propCalculator     = ThermalPropCalculator.Instance;

                double totalEenthalpyOfProductCarbonDioxide;
                double totalEenthalpyOfProductWater;
                double totalEenthalpyOfProductSulfer;
                double totalEenthalpyOfProduct;
                double totalFlueGasSpecificEnthalpy;

                double t = fuelInlet.Temperature.Value;;
                totalEenthalpyOfReactantInFuelInlet *= fuelMassFlowRate;
                double totalEnthalpyOfReactantOxygen = totalExactOxygenMassNeeded * propCalculator.CalculateEnthalpyOfFormation(t, oxygen);
                double totalEenthalpyOfReactants     = totalEenthalpyOfReactantInFuelInlet + totalEnthalpyOfReactantOxygen;

                double p       = flueGasOutlet.Pressure.Value;
                double tNew    = t;
                int    counter = 0;
                do
                {
                    counter++;
                    t = tNew;
                    totalEenthalpyOfProductCarbonDioxide = fuelMassFlowRate * moleFractionCarbon * propCalculator.CalculateEnthalpyOfFormation(t, carbonDioxide);
                    totalEenthalpyOfProductWater         = fuelMassFlowRate * moleFractionHydrogen * propCalculator.CalculateEnthalpyOfFormation(t, water);
                    totalEenthalpyOfProductSulfer        = fuelMassFlowRate * moleFractionSulfur * propCalculator.CalculateEnthalpyOfFormation(t, sulfurDioxide);
                    totalEenthalpyOfProduct      = totalEenthalpyOfProductCarbonDioxide + totalEenthalpyOfProductWater + totalEenthalpyOfProductSulfer;
                    totalHeatGenerated           = totalEenthalpyOfProduct - totalEenthalpyOfReactants;
                    totalFlueGasSpecificEnthalpy = (fuelInletEnthalpy + airInletEnthalpy + totalHeatGenerated) / totalFlueGasGenerated;

                    tNew = humidGasCalculator.GetDryBulbFromHumidEnthalpyHumidityAndPressure(totalFlueGasSpecificEnthalpy, flueGasMoistureContentDryBase, p);
                } while (Math.Abs(tNew - t) < 1.0e-6 && counter < 100);

                if (counter == 100)
                {
                }

                Calculate(flueGasOutlet.Temperature, tNew);
            }
        }