Skip to content

some problem in getsattemperature #54

@johnhe001

Description

@johnhe001

Why the saturation temperature values obtained using the GetSatTemperature() method cannot be used for the next step of the UpDatePT method? Here is an example of my partially error-free code:
using EngineeringUnits;
using SharpFluids;

namespace methane
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
double Qg, Ql, Vg, Vl, P, N, k, Tg, Tl, tk,Pg, Pl, densG,densL,satT,Dg,Ds,I1,I2,r;
private void button1_Click(object sender, EventArgs e)
{

        Qg = double.Parse(textBox1.Text);
        k = double.Parse(textBox2.Text);
        Vg = double.Parse(textBox6.Text);
        Vl = double.Parse(textBox7.Text);
        Tg = double.Parse(textBox3.Text);
        Tl = double.Parse(textBox4.Text);
        P = double.Parse(textBox5.Text) * 0.001;
        Pg = double.Parse(textBox8.Text) + 0.101325;
        Pl = double.Parse(textBox9.Text) + 0.101325;
        //tk = double.Parse(textBox10.Text);
        Fluid fluid = new(FluidList.Methane);
        fluid.UpdatePT(Pressure.FromMegapascal(Pg), Temperature.FromDegreesCelsius(Tg));
        Fluid fluid2 = new(FluidList.Methane);
        fluid2.UpdatePT(Pressure.FromMegapascal(Pl), Temperature.FromDegreesCelsius(Tl));
        densG = fluid.Density.KilogramPerCubicMeter;
        densL = fluid2.Density.KilogramPerCubicMeter;
        Fluid fluid5 = new(FluidList.Methane);
        fluid5.UpdatePT(Pressure.FromMegapascal(Pl), Temperature.FromDegreesCelsius(Tg));
        I1 = fluid5.Enthalpy.KilojoulePerKilogram;
        Fluid fluid3 = new Fluid(FluidList.Methane);
        fluid3.UpdatePT(Pressure.FromMegapascal(Pl), Temperature.FromDegreesCelsius(Tg));
        satT = fluid3.GetSatTemperature(Pressure.FromMegapascal(Pl)).DegreeCelsius;
        Fluid fluid6 = new(FluidList.Methane);
        fluid6.UpdatePT(Pressure.FromMegapascal(Pl), Temperature.FromDegreesCelsius(satT));
        r = fluid6.Enthalpy.KilojoulePerKilogram;

When the above line is running, the last line of code gives an error prompt:“System.NullReferenceException:“Object reference not set to an instance of an object.”
Please help me to answer it, thank you very much

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions