예제 #1
0
        /// <summary>
        /// Calc monetary value of in excess produced methane in €/d
        /// </summary>
        /// <param name="u">u - 3dim vector of in excess produced biogas in m³/d
        /// h2, ch4, co2</param>
        /// <param name="myPlant"></param>
        /// <param name="myFitnessParams"></param>
        /// <returns></returns>
        private static double calcValueOfMethaneExcess(double[] u, biogas.plant myPlant,
                                                       biooptim.fitness_params myFitnessParams)
        {
            string bhkw_id = myPlant.getCHPID(1);

            // electrical and thermal energy produced by in excess produced biogas
            // measured in kWh/d
            double Pel_kWh_d, Ptherm_kWh_d;

            myPlant.burnBiogas(bhkw_id, u, out Pel_kWh_d, out Ptherm_kWh_d);

            //

            // €/d : get money that we would get by selling produced energy
            double valueMethaneExcess = sellEnergy(Pel_kWh_d, Ptherm_kWh_d,
                                                   myPlant, myFitnessParams);

            return(valueMethaneExcess);
        }
예제 #2
0
        /// <summary>
        /// simulates all chps of the plant
        /// </summary>
        /// <param name="t"></param>
        /// <param name="u">
        /// number of digesters times n_gases dimensional vector
        /// with the biogas streams for each digester measured in m^3/d</param>
        /// <param name="mySensors"></param>
        /// <param name="myPlant"></param>
        /// <param name="gas2chpsplittype">"threshold", "one2one", "fiftyfifty"</param>
        /// <returns>
        /// produced electrical power for each chp in kW and the biogas excess in m³/d
        /// dimension: number of chps + 1
        /// </returns>
        public static double[] run(double t, double[] u, //double deltatime,
                                   biogas.sensors mySensors, biogas.plant myPlant, string gas2chpsplittype)
        {
            //
            // total biogas production [m³/d]
            // total biogas production splitted into components [m³d]
            // biogas for each chp splitted into components
            // biogas excess [m³/d]
            double[] biogas_vec;

            try
            {
                // split biogas upon available chps
                mySensors.measureVec(t, "total_biogas_",
                                     myPlant, u, gas2chpsplittype, out biogas_vec);
            }
            catch (exception e)
            {
                biogas_vec = math.zeros(11);
                //throw(e);
            }

            //

            int num_chps = myPlant.getNumCHPs(); // number of digesters

            // 2dim vector, 1st value, produced electrical energy / day
            // 2nd value: produced thermal energy / day
            double[] P_kWh_d;

            // returned vector by this method
            // produced electrical power for each chp in kW and the biogas excess in m³/d
            // dimension: number of chps + 1
            double[] outvec = new double[num_chps + 1];

            //

            double[] Psum_el_th = new double[2];
            Psum_el_th[0] = 0;
            Psum_el_th[1] = 0;

            //

            for (int ichp = 0; ichp < num_chps; ichp++)
            {
                // biogas which is burned by chp ichp
                double[] biogas_chp;

                try
                {
                    // biogas which is burned by chp ichp
                    biogas_chp = math.getrows(biogas_vec,
                                              1 + (1 + ichp) * (int)biogas.BioGas.n_gases,
                                              1 + (2 + ichp) * (int)biogas.BioGas.n_gases - 1);
                }
                catch (exception e)
                {
                    biogas_chp = math.zeros(3);
                    //throw (e);
                }

                try
                {
                    // burn biogas in chp ichp
                    mySensors.measureVec(t, "energyProduction_" + myPlant.getCHPID(ichp + 1),
                                         myPlant, biogas_chp, out P_kWh_d);
                }
                catch (exception e)
                {
                    P_kWh_d = math.zeros(2);
                    //throw (e);
                }

                // electrical energy in kW
                outvec[ichp] = P_kWh_d[0] / 24; // convert from kWh/d -> kW

                Psum_el_th[0] += P_kWh_d[0];
                Psum_el_th[1] += P_kWh_d[1];
            }

            // insert biogas excess in m^3/d
            outvec[num_chps] = biogas_vec[biogas_vec.Length - 1];

            try
            {
                //
                // measure total energy production of plant in kWh/d
                mySensors.measureVec(t, "energyProdSum", Psum_el_th);
            }
            catch (exception e)
            {
                //throw(e);
            }

            //

            return(outvec);
        }