Beispiel #1
0
        public virtual void FillEquationSystem(EquationSystem problem)
        {
            foreach (var vari in Variables)
            {
                vari.ModelClass = Class;
                vari.ModelName  = Name;

                if (vari.IsFixed)
                {
                    if (!problem.TreatFixedVariablesAsConstants && !vari.IsConstant)
                    {
                        //if (vari.DefiningExpression == null)
                        //{
                        //    problem.AddVariables(vari);
                        //}
                        double scale = 1.0;
                        if (vari.Dimension == PhysicalDimension.Pressure)
                        {
                            scale = 1e5;
                        }
                        if (vari.Dimension == PhysicalDimension.Temperature)
                        {
                            scale = 1e3;
                        }
                        AddEquationToEquationSystem(problem, (vari / scale).IsEqualTo(vari.ValueInSI / scale), "Specification");
                        // problem.RemoveVariable(vari);
                    }
                    else
                    {
                        problem.RemoveVariable(vari);
                    }
                }

                if (vari.DefiningExpression != null)
                {
                    problem.AddDefinedVariables(vari);
                }
                else
                {
                    if (!(problem.TreatFixedVariablesAsConstants && vari.IsFixed) && !vari.IsConstant)
                    {
                        problem.AddVariables(vari);
                    }
                }
            }
        }