public void calculate()
{
//this is where the actual calculation begins ..
//lets defin the constants..
try
{
if(textBox1.Text != "" && textBox2.Text != "") {
if (radioButton1.Checked == true)
{
//lets grab from the textbox input.
if (textBox1.Text == "" || textBox2.Text == "" || tb_atm_pressure.Text == "")
{
MessageBox.Show("Please enter all parameter properly");
return;
}
double temperature = Double.Parse(textBox1.Text.Trim());
double humidity = Double.Parse(textBox2.Text.Trim());
double Patm = double.Parse(tb_atm_pressure.Text);
// tb_atm_pressure.Text = Patm.ToString();
CalculatePsymetric(temperature, humidity, Patm);
//This one is dew point
textBox4.Text = Math.Round(output_dew_point, 4).ToString();
textBox8.Text = Math.Round(output_partial_pressure_of_water, 4).ToString();
textBox10.Text = Math.Round(output_mixing_ratio, 4).ToString();
textBox11.Text = Math.Round(output_enthalpy, 4).ToString();
textBox9.Text = Math.Round(output_mol_mass_of_water, 4).ToString();
}
else if (radioButton2.Checked == true)
{
if (textBox1.Text == "" || textBox2.Text == "" || tb_atm_pressure.Text == "")
{
MessageBox.Show("Please enter all parameter properly");
return;
}
//lets grab from the textbox input.
double temperature = Double.Parse(textBox1.Text.Trim()); // in deg F
double humidity = Double.Parse(textBox2.Text.Trim()); // in % no change
double Patm = 29.913872; //is in In Hg need to be converted to Hpa
try
{
Patm = double.Parse(tb_atm_pressure.Text);
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
tb_atm_pressure.Text = Patm.ToString();
//Thes value needs to be converted first
double IP_temp = (temperature - 32) / 1.8;// in deg C now
double IP_hum = humidity;//Same no change
double IP_pressure = 33.8639 * Patm;//in hpa now
CalculatePsymetric(IP_temp, IP_hum, IP_pressure);
//now output need to be converted too.
double ip_dew_point = output_dew_point * 1.8 + 32;//in Deg F
double ip_partial_pressure = output_partial_pressure_of_water * 0.001;//in lb/lb
double ip_mixing_ratio = output_mixing_ratio * 0.001; //in lb/lb
double ip_enthalpy = output_enthalpy * 0.429923;// in btu/lb
double ip_mol_mass = output_mol_mass_of_water * 0.001;
//This one is dew point
textBox4.Text = Math.Round(ip_dew_point, 4).ToString();
textBox8.Text = Math.Round(ip_partial_pressure, 4).ToString();
textBox10.Text = Math.Round(ip_mixing_ratio, 4).ToString();
textBox11.Text = Math.Round(ip_enthalpy, 4).ToString();
textBox9.Text = Math.Round(ip_mol_mass, 4).ToString();
}
}//close of if
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
textBox1.Text = "";
textBox2.Text = "";
//lets set the values..
tb_atm_pressure.Text = "";
//textBox5.Text = "";
//textBox6.Text = "";
//textBox7.Text = "";
textBox9.Text = "";
}
//for the EU unit just check if EU unit was selected of not if selected then convert
//this values here...
}