Challenge

Project 1 - Parsing NASA thermodynamic data

PROJECT 1 :- Parsing NASA thermodynamic data

AIM :- 

1. Write a function that extracts the 14 co-efficients and calculates the enthalpy, entropy and specific heats for all the species in the data file. You will be reading this file NASA thermodynamic data(use fopen and fgetl). The formulae are shown below.

 Here R is the universal gas constant, T is the temeprature

2. Calculate the molecular weight of each species and display it in the command window.

3. Plot the Cp, Enthalpy and Entropy for the local temperature range (low temperature : high temperature) specific for each species.

Introduction:-

Parsing, syntax analysis, or syntactic analysis is the process of analyzing a string of symbols, either in natural language, computer languages or data structures, conforming to the rules of a formal grammar. The term parsing comes from Latin pars (orationis), meaning part (of speech).

The term has slightly different meanings in different branches of linguistics and computer science. Traditional sentence parsing is often performed as a method of understanding the exact meaning of a sentence or word, sometimes with the aid of devices such as sentence diagrams. It usually emphasizes the importance of grammatical divisions such as subject and predicate.

Within computational linguistics the term is used to refer to the formal analysis by a computer of a sentence or other string of words into its constituents, resulting in a parse tree showing their syntactic relation to each other, which may also contain semantic and other information (p-values).Some parsing algorithms may generate a parse forest or list of parse trees for a syntactically ambiguous input.

The term is also used in psycholinguistics when describing language comprehension. In this context, parsing refers to the way that human beings analyze a sentence or phrase (in spoken language or text) "in terms of grammatical constituents, identifying the parts of speech, syntactic relations, etc.This term is especially common when discussing which linguistic cues help speakers interpret garden-path sentences.

Within computer science, the term is used in the analysis of computer languages, referring to the syntactic analysis of the input code into its component parts in order to facilitate the writing of compilers and interpreters. The term may also be used to describe a split or separation.

Types of parsers

The task of the parser is essentially to determine if and how the input can be derived from the start symbol of the grammar. This can be done in essentially two ways:

  • Top-down parsing - Top-down parsing can be viewed as an attempt to find left-most derivations of an input-stream by searching for parse trees using a top-down expansion of the given formal grammar rules. Tokens are consumed from left to right. Inclusive choice is used to accommodate ambiguity by expanding all alternative right-hand-sides of grammar rules. This is known as the primordial soup approach. Very similar to sentence diagramming, primordial soup breaks down the constituencies of sentences.
  • Bottom-up parsing - A parser can start with the input and attempt to rewrite it to the start symbol. Intuitively, the parser attempts to locate the most basic elements, then the elements containing these, and so on. LR parsers are examples of bottom-up parsers. Another term used for this type of parser is Shift-Reduce parsing.

Code :-

1.We first need to use the following commands to clear and close the all previously entered codes and the present values

clear all

close all

clc

2. starting with the given NASA thermo file. To open this file , we can use the command of fopen. This command will open the Thermo file and then put it into the red format. Then proceed to write a logic that will read the lines in this file . Also need to calculate the molecular weight of all the species in the file as well 

3. In the next line, request the code to read the next line in the file .Then assign all the letters and numbers in this line to a variable .extract the global low, mid and high temperature for this .Proceed to extract data from this variable. the split the string and assign another variable to the split string. from the second variable that set, extract the required data

4. Give the code to read these lines,again create new variables to assign in this code accordingly. then apply the global high temperature 

5.In the next line of the code, read and skip these lines and begin with an exclamation mark and general comments

6.To proceed with the code, start a for loop that will perform all the commands give inside of it. Read the line and then assign a variable to split the string create in that line. Read the species name from that file. To read the name of file again create another variable and then split that string .Use the first set of letters till  getting blank space in the file. Use the strsplit command to split all the string set of words. The first set of letters will represent the species name in the flle .

7.After this,need to make a directory to store all the graphs that we will be plotting .To make a directory use the command of mkdir and create a directory of the spicies name

8.Every species has its own local low , mid and high temp. Need to read it separately for every species and then assign a variable for it.

9. Next line get the coefficient as well. That coefficients 1 to 7 are for high temperature and coefficients from 8 to 14 are low as well. In every line of the code , read all the coefficient and then store them in their variables. For that store the string in one variable and split this string to another variable. To use the findstr command to locate the string. The command searches the longer of the two input arguments for the occurrence of shorter argument. return the starting of each occurrence in double array k. if no occurrence , then findstr returns the empty array. Then from this second variable extract the coefficients present in that line.

10. Now, to calculate the thermodynamic properties from the coefficients, if the input temperature is below the local mid temp, then the low temp coefficients are to be considered, or if the temperature is above the local mid temp and below the local high temp, then the high temp coefficient are to be considered. The common variable and the changed the coefficients according to temp set.

  

Here:

Cp = specific heat 

H = enthalpy

S = entropy

R = universal gas constant 

a1,a2,a3,a4,a5,a6,a7 = thermal coefficients according to temp at which is recorded

11.In next step, plot the graphs for the calculated properties and temp. To plot these graphs, use the plot command  and label x and y . 

12.In the next step, write a code to calculate the molecular weight of the species. In this code use if and else codition again. Start by stating the elements that were use in the entire file and then create an array from it. Create an array of the atomic mass of all the elements. The atomic mass and element array should have exactly identical indices. Define a for loop that runs the variables k.Then define an if else loop for the species name.After this define another variable z that will compatre the species name and the atoms array and then apply the condition that is being set in the if else loop. after this will get a1 at the index where the system has found a match.then use this to find the corresponding atomic mass for the calculation of the molecular weight. 

13. In the last step, Print the results of the molecular weight into the command window using the fprintf command

Your portfolio, next

Ship work like this
in your own course.

Talk to a career counsellor

Free 20-minute call. We'll map the right course to where you want to work.

By submitting you agree to our Terms and Privacy Policy.

Talk to a career counsellor

Free 20-minute call. We'll map the right course to where you want to work.

By submitting you agree to our Terms and Privacy Policy.