Project 1 - Parsing NASA thermodynamic data
Aim: to write a code in matlab to parse the NASA Thermodynamics data file and then calculate the thermodynamics properties of various gas species
Objective:
1. To write a function that ectract the 14 coefficients and calculate the enthalpy , entropy and specific heat for all the NASA thermodynamic data file "thermo.dat".
2. To calculate the molecular weight of each species and display it in the command window.
3. To plot the Cp, Enthalpy and Entropy for the Local temperature range(low temperature: high temperature)specific for each species.
4. To save the plots as images with appropriate names and dump them in separate folders for each species with suitable name automatically.
FIle parsing:
File parsing refers to how information can be read from a particular text file or any type of file and how that information can be used in a computer program.
step1- Define the function step 2- Create an input parser object
step 3- Add input to the scheme. step 4- set properties to adjust parsing
Step 5- parse the inputs step 6-Use the inputs in function.
NASA Thermodynamic File
THERMO.dat file is a data file containing 14 coefficients for 53 different elements givens by NASA. These coefficients are utilized to calculate the specific heat , enthalpy and entropy for a particlar element. each element has its own range of lacal temperature. Below screenshot of the THERMO.dat file is displayed.
List of 53 Elements contained in 'THERMO.dat'file:
AR C C2H C2H2 C2H3 C2H4
C2H5 C2H6 C3H7 C3H8 CH CH2
CH2(S) CH2CHO CH2CO CH2O CH2OH CH3
CH3CHO CH3O CH3OH CH4 CN CO
CO2 H H2 H2CN H2O H2O2
HCCO CCOH HCN HCNN HCNO HCO
HNCO HNO HO2 HOCH N N2
N2O NCO NH NH2 NH3 NNH
NO NO2 O O2 OH
Enthalpy, Entropy and specific Heat:
Enthalpy,entropy and specific heat of various species values at different temparature are required extensively to analyze the thermodynamics process.
NASA came up with polynomials that can be used to evaluate thermodynamic properties such as Cp,H and S. THey have documented the coefficients that are required to evaluate these polynomials.
Coding Functions:
1.Specific Heat:
It is the amount of energy that must be added in the form of heat to one unit of mass of the substance in order to cause an increase of one unit in its temperature.
Cp=(a1+a2T+a3T^2+a4T^3+a5T^4)*R
2.Entropy:
Entropy, the measure of a system's thermal energy per unit temperature that is unavailable for doing useful work. Bacause work is obtained from ordered molecular motion the amount of entropy is also a measure of the molecular disorder or randomness of a system. the concept of entropy provides deep insight into the direction of spontaneous change for many everyday phenomena.
S=(a1lnT+a2T+a3T^2/2+a4T^3/3+a5T^4/4+a7)*R
3.Enthalpy:
Enthalpy, a property of a thermodynamics system is equal to the system's internal energy plus the product of its pressure and volume .In a system enclosed so as to prevent the mass transfer for processes at constant pressure the heat absorbed or released equal the change in enthalpy.
H=(a1+a2T/2+a3T^2/3+a4T^3/4+a5T^4/5+a6/T)*R*T
4. Molecular weight:
The molecular mas is the mass of a given molecular: it is measured in daltons. Different molecules of the same compound may have different molecular masses because they contains different of an element.
Code Explanation:
1.'clear all '-clear all the variables in the workspace.
'close all '- closes all the plots and figures .
'clc'- clears the command window.
2. Making a directory using 'mkdir' with location address.
3.After that reading the text file 'Thermo.dat'file and opening it by using 'fopen' and 'r' as reading command.
4.For reading the line in a text file using 'fgetl'.
5.To obtain the temperature range from the Thermo.dat file, using 'strsplit' to split the temperature into a particular string cell.
6.Used 'str2num' for converting string cell to numbers.
7.Dividing the temperature into a string and them converted to a number so that temperature values can be used separately to solve the NASA thermodynamics.
8. Using 'for & end'loops to skip the next three comment lines in the text file.
9. Reading all the 53 species to plot specific heat (cp),enthalpy(H) and entropy(s) with temperature values , and to find the molecular weights.
10.Used 'for'loop to read 53 species.
11.Used'strfind' to find string.
12.Using 'linspace'specified the temperature range from low to high.
13. Adding universal gas constant value 'R'.
14. Extracted higher and lower temperature coefficient by reading line by line from the species.
15. calling specific heat, enthalpy function codes.
16. calculating molecular weight.