public Variable GetVaporDensityExpression(ThermodynamicSystem system, MolecularComponent comp, Variable T, Variable p) { var R = new Variable("R", 8.3144621, SI.J / SI.mol / SI.K); var expression = p / (R * T); // expression *= Unit.GetConversionFactor(SI.mol / (SI.m ^ 3), system.VariableFactory.Internal.UnitDictionary[PhysicalDimension.MolarDensity]); Variable prop = new Variable("DENV" + "(" + T.FullName + ")", 1); prop.Subscript = comp.ID; prop.BindTo(expression); return(prop); }
public double GetParam(string matrix, MolecularComponent c1, MolecularComponent c2) { var i = _system.Components.IndexOf(c1); var j = _system.Components.IndexOf(c2); if (i >= 0 && j >= 0 && Matrices.ContainsKey(matrix)) { return(Matrices[matrix][i, j]); } return(0); }
public BinaryInteractionParameterSet SetParam(string matrix, MolecularComponent c1, MolecularComponent c2, double value) { var i = _system.Components.IndexOf(c1); var j = _system.Components.IndexOf(c2); if (i >= 0 && j >= 0 && Matrices.ContainsKey(matrix)) { Matrices[matrix][i, j] = value; } return(this); }
public ThermodynamicSystem AddComponent(MolecularComponent comp) { Components.Add(comp); var enthalpy = PureEnthalpyFunction.Create(this, comp); enthalpy.ReferenceState = PhaseState.Vapour; enthalpy.Tref.ValueInSI = 298.15; EnthalpyMethod.PureComponentEnthalpies.Add(enthalpy); return(this); }
public static PureEnthalpyFunction Create(ThermodynamicSystem sys, MolecularComponent comp) { var func = new PureEnthalpyFunction(); func.Component = comp; func.Tref = sys.VariableFactory.CreateVariable("Tref", "Reference temperature for enthalpy calculation", PhysicalDimension.Temperature); func.Href = sys.VariableFactory.CreateVariable("Href", "Reference enthalpy for enthalpy calculation", PhysicalDimension.SpecificMolarEnthalpy); func.PhaseChangeAtSystemTemperature = true; func.TPhaseChange = sys.VariableFactory.CreateVariable("TPC", "Temperature of phase change for enthalpy calculation", PhysicalDimension.Temperature); func.ReferenceState = PhaseState.Vapour; return(func); }
public Variable GetVaporViscosityExpression(ThermodynamicSystem system, MolecularComponent comp, Variable T, Variable p) { var func = comp.GetFunction(EvaluatedProperties.VaporViscosity); var expression = system.CorrelationFactory.CreateExpression(func.Type, func, T, null, null); expression *= Unit.GetConversionFactor(func.YUnit, system.VariableFactory.Internal.UnitDictionary[PhysicalDimension.DynamicViscosity]); Variable prop = new Variable(system.CorrelationFactory.GetVariableNameForProperty(func.Property) + "(" + T.FullName + ")", 1); prop.LowerBound = 0; prop.Subscript = comp.ID; prop.BindTo(expression); return(prop); }
public Variable GetVaporPressure(ThermodynamicSystem system, MolecularComponent comp, Variable T) { var func = comp.GetFunction(EvaluatedProperties.VaporPressure); var expr = system.CorrelationFactory.CreateExpression(func.Type, func, T, comp.GetConstant(ConstantProperties.CriticalTemperature), comp.GetConstant(ConstantProperties.CriticalPressure)); expr *= Unit.GetConversionFactor(func.YUnit, system.VariableFactory.Internal.UnitDictionary[PhysicalDimension.Pressure]); //var exprmax = system.CorrelationFactory.CreateExpression(func.Type, func, comp.GetConstant(ConstantProperties.CriticalTemperature), comp.GetConstant(ConstantProperties.CriticalTemperature), comp.GetConstant(ConstantProperties.CriticalPressure)); //var maxVal = exprmax.Eval(new Evaluator()); Variable prop = new Variable(system.CorrelationFactory.GetVariableNameForProperty(func.Property) + "(" + T.FullName + ")", 1); prop.Subscript = comp.ID; // prop.UpperBound = 1e9; prop.BindTo(expr); return(prop); }
public Variable GetLiquidDensityExpression(ThermodynamicSystem system, MolecularComponent comp, Variable T, Variable p) { var func = comp.GetFunction(EvaluatedProperties.LiquidDensity); var TC = comp.GetConstant(ConstantProperties.CriticalTemperature); var expression = system.CorrelationFactory.CreateExpression(func.Type, func, T, TC, null); expression *= Unit.GetConversionFactor(func.YUnit, system.VariableFactory.Internal.UnitDictionary[PhysicalDimension.MolarDensity]); var expresssionDENV = GetVaporDensityExpression(system, comp, T, p); Variable prop = new Variable(system.CorrelationFactory.GetVariableNameForProperty(func.Property) + "(" + T.FullName + ")", 1); prop.LowerBound = 1e-6; prop.UpperBound = 1e8; prop.Subscript = comp.ID; prop.BindTo(new SafeLiquidDensity(expression, expresssionDENV)); //prop.BindTo(expression); return(prop); }
public Expression GetLiquidHeatCapacityIntegralExpression(ThermodynamicSystem system, MolecularComponent comp, Variable T, Variable Tref) { Expression expression = null; var func = comp.GetFunction(EvaluatedProperties.LiquidHeatCapacity); switch (func.Type) { case FunctionType.Polynomial: expression = system.CorrelationFactory.CreateIntegratedExpression(FunctionType.PolynomialIntegrated, func, T, Tref); expression *= Unit.GetConversionFactor(func.YUnit, system.VariableFactory.Internal.UnitDictionary[PhysicalDimension.HeatCapacity]); break; case FunctionType.AlyLee: expression = system.CorrelationFactory.CreateIntegratedExpression(FunctionType.Dippr117, func, T, Tref); expression *= Unit.GetConversionFactor(func.YUnit, system.VariableFactory.Internal.UnitDictionary[PhysicalDimension.HeatCapacity]); break; } Variable prop = new Variable(system.CorrelationFactory.GetVariableNameForProperty(func.Property) + "_INT" + "(" + T.FullName + ")", 1); prop.Subscript = comp.ID; prop.BindTo(expression); return(prop); }
public Expression GetLiquidHeatCapacityExpression(ThermodynamicSystem system, MolecularComponent comp, Variable T) { var func = comp.GetFunction(EvaluatedProperties.LiquidHeatCapacity); var expr = system.CorrelationFactory.CreateExpression(func.Type, func, T, comp.GetConstant(ConstantProperties.CriticalTemperature), comp.GetConstant(ConstantProperties.CriticalPressure)); expr *= Unit.GetConversionFactor(func.YUnit, system.VariableFactory.Internal.UnitDictionary[PhysicalDimension.HeatCapacity]); Variable prop = new Variable(system.CorrelationFactory.GetVariableNameForProperty(func.Property) + "(" + T.FullName + ")", 1); prop.Subscript = comp.ID; prop.BindTo(expr); return(prop); }