Air Class


Air Class

Since a lot of the functionality needed to model perfect gas mixtures has been built into the PerfectGas class it is a very simple matter to create classes for specific perfect gas mixtures. The Air class represents an air gas mixture. The only thing the Air class does is to define a constructor that accepts temperature and pressure values as arguments. It then adds in the name , molar mass, specific heat, and reference entropy data for air and calls the PerfectGas constructor. The Air class inherits all of the methods declared in the PerfectGas class.

 package TechJava.Gas; public class Air extends PerfectGas {   //  The Air class declares one constructor that calls   //  the PerfectGas constructor passing it the   //  specified temperature and pressure and the   //  molarMass, specific heat and reference entropy   //  values for air.   public Air(double temperature, double pressure) {     super("Air",temperature, 0.02885,                 pressure, 3.5, 162.665);   } } 

To make sure everything is working properly, let's write a driver program that will create an Air object and access the data associated with the object. The AirDriver class source code is shown next . Remember, that because the AbstractGas , PerfectGas , and Air classes have been placed in the TechJava.Gas package, you will have to place the source code for those classes in a \TechJava\Gas directory, compile them from the package root directory, and add the package root directory to your CLASSPATH environment variable.

 import TechJava.Gas.*; public class AirDriver {   public static void main(String args[]) {     Air air = new Air(500.0, 100000.0);     System.out.println("gas mixture name = " +                         air.getName());     System.out.println("pressure = " +                         air.getPressure() + " N/m^2");     System.out.println("temperature = " +                         air.getTemperature() + " K");     System.out.println("density = " +                         air.getDensity() + " kg/m^3");     System.out.println("molar mass = " +                        air.getMolarMass() + " kg/mole");     System.out.println("viscosity = " +                         air.getViscosity() + " kg/m-s");     System.out.println("enthalpy = " +                         air.getEnthalpy() + " J/mole");     System.out.println("entropy = " +                         air.getEntropy() + " J/mole-K");    } } 

Output ”

 gas mixture name = Air pressure = 100000.0 N/m^2 temperature = 500.0 K density = 0.6939758804292788 kg/m^3 molar mass = 0.02885 kg/mole viscosity = 2.6705333479641985E-5 kg/m-s enthalpy = 14550.2175 J/mole entropy = 209.50034335732423 J/mole-K 


Technical Java. Applications for Science and Engineering
Technical Java: Applications for Science and Engineering
ISBN: 0131018159
EAN: 2147483647
Year: 2003
Pages: 281
Authors: Grant Palmer

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net