Ejemplo n.º 1
0
        // -------------------------------------------------------------------------------------
        //                              !!! CONSTRUCTOR METHODS !!!
        // -------------------------------------------------------------------------------------

        /// <summary>
        /// constructor
        ///
        /// creates a new sludge object, which has parameters the same as the mean
        /// substrate feed (Rf, RP, RL, ADL, VS), the given TS content and
        /// a density of 1000 kg/m³
        ///
        /// TS measured in % FM
        ///
        /// sludge is created out of the weighted mean of the given substrates,
        /// which should be the substrates fed on the plant.
        ///
        /// </summary>
        /// <param name="mySubstrates">list of substrates</param>
        /// <param name="Q">must be measured in m³/d</param>
        /// <param name="TS">must be measured in % FM</param>
        public sludge(substrates mySubstrates, double[] Q, double TS) : base()
        {
            physValue RF;
            physValue RP;
            physValue RL;
            physValue ADL;
            physValue VS;

            try
            {
                mySubstrates.get_weighted_mean_of(Q, "RF", out RF);
                mySubstrates.get_weighted_mean_of(Q, "RP", out RP);
                mySubstrates.get_weighted_mean_of(Q, "RL", out RL);
                mySubstrates.get_weighted_mean_of(Q, "ADL", out ADL);
                mySubstrates.get_weighted_mean_of(Q, "VS", out VS);

                set_params_of("RF", RF.Value, "RP", RP.Value, "RL", RL.Value,
                              "ADL", ADL.Value, "VS", VS.Value);

                set_params_of("TS", TS);
            }
            catch (exception e)
            {
                Console.WriteLine(e.Message);
                // TODO - maybe do something
                LogError.Log_Err("sludge constructor1", e);
            }

            // TODO: could calculate rho here instead of taking 1000 kg/m^3
            //set_params_of("rho", new physValue(1000, "kg/m^3"));
        }
Ejemplo n.º 2
0
        public Window1(Control.ResultViewControl resultControl)
        {
            resultControlInit = resultControl;
            InitializeComponent();
            CenterWindowOnScreen();
            connectionString    = ConfigurationManager.AppSettings["DefaultDBConn"]; //System.Configuration.ConfigurationSettings.AppSettings["FastDBConn"];
            CurrentDatabaseName = ConfigurationManager.AppSettings["DefaultDatabase"];

            connectionString = connectionString + "Database=" + CurrentDatabaseName + ";";
            MainWindow m = new MainWindow();

            try
            {
                List <Schema> schemas   = MySQLData.DataAccess.ADODataBridge.getSchemaTree(connectionString, CurrentDatabaseName, ConfigurationManager.AppSettings["DerivedTablesPath"]);//DataAccess.GetDatabases();
                MainViewModel viewModel = new MainViewModel(schemas);

                m.MainTreeView.DataContext = viewModel;
                listOfTable = new List <MySQLData.Table>();
                foreach (Schema schema in schemas)
                {
                    listOfTable.AddRange(schema.tables);
                }
                if (listOfTable != null)
                {
                }
            }
            catch (MySql.Data.MySqlClient.MySqlException ex)
            {
                if (isErrorLoggingOn)
                {
                    LogError.Log_Err("MainWindow Constructor", ex);
                    DisplayErrorMessage();
                }
            }
            catch (Exception ex)
            {
                if (isErrorLoggingOn)
                {
                    LogError.Log_Err("MainWindow Constructor", ex);
                    DisplayErrorMessage();
                }
            }
            var collView = CollectionViewSource.GetDefaultView(m.tabControlCustomQuery.Items);

            collView.CurrentChanging += this.OnTabItemSelecting;
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Measure OLR of a digester
        ///
        /// type 7
        ///
        /// TODO: größtenteils identisch mit TS_sensor, man könnte was zusammen legen
        /// </summary>
        /// <param name="x">ADM state vector</param>
        /// <param name="myPlant"></param>
        /// <param name="mySubstrates">list of substrates</param>
        /// <param name="mySensors"></param>
        /// <param name="Q">
        /// substrate feed and recirculation sludge going into fermenter in m³/d
        /// first values are Q for substrates, then pumped sludge going into digester
        /// dimension: always number of substrates + number of digesters
        /// </param>
        /// <param name="par"></param>
        /// <returns></returns>
        override protected physValue[] doMeasurement(double[] x, biogas.plant myPlant,
                                                     biogas.substrates mySubstrates, biogas.sensors mySensors,
                                                     double[] Q, params double[] par)
        {
            physValue[] values = new physValue[1];

            // TODO: so abändern, dass die aufgerufene methode calcOLR immer
            // feed und sludge übergeben werden. nicht oder

            // number of substrates
            int n_substrate = mySubstrates.getNumSubstrates();

            double Qsum = math.sum(Q);

            if (Q.Length < n_substrate)
            {
                throw new exception(String.Format(
                                        "Q.Length < n_substrate: {0} < {1}!", Q.Length, n_substrate));
            }

            double[] Qsubstrates = new double[n_substrate];

            // volumeflow for substrates
            for (int isubstrate = 0; isubstrate < n_substrate; isubstrate++)
            {
                Qsubstrates[isubstrate] = Q[isubstrate];
            }

            //

            biogas.substrates substrates_or_sludge;

            //
            List <double> Q_s_or_s = new List <double>();

            // if no substrate is going into the fermenter we have to take the
            // TS from the digesters sludge going into this digester to calculate a
            // sludge. If there is substrate going into the digester we ignore
            // recirculation sludge, because the COD content inside the digester is
            // already influenced by the recirculated COD, so a high recirculation leads
            // to a reduction of the COD content inside the digester and then also to a
            // TS content reduction.
            if (math.sum(Qsubstrates) == 0)
            {
                substrates_or_sludge = new biogas.substrates();

                int ifermenter = 0;

                //

                for (int iflux = n_substrate; iflux < Q.Length; iflux++)
                {
                    string digester_id = myPlant.getDigesterID(ifermenter + 1);

                    double TS_digester, VS_digester = 0;

                    try
                    {
                        mySensors.getCurrentMeasurementD("TS_" + digester_id + "_3", out TS_digester);
                        mySensors.getCurrentMeasurementD("VS_" + digester_id + "_3", out VS_digester);

                        // TODO - warum 4, wenn Fermenter abgestürzt ist, dann ist TS < 2
                        // was zu doofen Fehlermeldungen führt mit calcNfE und boundNDF, wenn man
                        // VS unten in biogas.sludge setzt. deshalb hier abfrage
                        if (TS_digester < 4 /*double.Epsilon*/)
                        {
                            TS_digester = 11;
                        }
                        // TODO - herausfinden warum 15
                        if (VS_digester < 20 /*double.Epsilon*/)
                        {
                            VS_digester = 85; // 85 % TS
                        }
                    }
                    catch
                    {
                        TS_digester = 11;
                        VS_digester = 85;
                    }

                    try
                    {
                        substrates_or_sludge.addSubstrate(
                            new biogas.sludge(mySubstrates, math.ones(n_substrate),
                                              TS_digester, VS_digester));
                    }
                    catch (exception e)
                    {
                        LogError.Log_Err(String.Format("OLR_sensor.doMeasurement, VS: {0}, TS: {1}",
                                                       VS_digester, TS_digester), e);
                        throw (e);
                    }

                    ifermenter = ifermenter + 1;
                }

                //

                for (int isubstrate = n_substrate; isubstrate < Q.Length; isubstrate++)
                {
                    Q_s_or_s.Add(Q[isubstrate]);
                }
            }
            else
            {
                substrates_or_sludge = mySubstrates;

                for (int isubstrate = 0; isubstrate < Qsubstrates.Length; isubstrate++)
                {
                    Q_s_or_s.Add(Qsubstrates[isubstrate]);
                }
            }

            //

            digester myDigester = myPlant.getDigesterByID(id_suffix);

            try
            {
                values[0] = myDigester.calcOLR(x, substrates_or_sludge, Q_s_or_s.ToArray(), Qsum);
            }
            catch (exception e)
            {
                LogError.Log_Err("OLR_sensor.doMeasurement2", e);
                throw (e);
            }

            //

            return(values);
        }