Parsing NASA Thermodynamic data for multiple specified Gas Species and Calculating the Thermodynamic Properties

Aim: To parse the NASA Thermodynamc Properties data file, calculate thermodynamic properties and plot the characteristics.

Introduction:

NASA's thermodynamic properties file consists of multiple species of gases, their respective operating temperature ranges, and coefficients to calculate thermodynamic properties. There are 14 coefficients for each specie of which the first 7 are "high temperature coefficients" and the next 7 are "low temperature coefficients". 14 coeffs are split into 3 lines, 5 each in the first 2 and 4 in the 3rd. This makes reading the line and isolating the coefficient a challenge, so understanding the positions of the coefficients and checking for repetition across both lines is the key here.

Once extracted, the below equations are used to calculate Specific heat (Cp), enthalpy (H) and entropy (S) for each of the 53 species in the file.

The values generated are then plotted vs local temperatures.

Procedure:

  1. File is read.
  2. Global temperatures line is read and global temps extracted.
  3. Then we traverse the commented lines to reach the first specie line.
  4. Up until this point, we used "count" and "lines" to count lines traversed and total number of lines in the data file.
  5. "lines/4" gives 53, which is the total number of species in the file, which is useda as the final value for the loop variable.
  6. specie line is read, specie is extracted and displayed.
  7. Local temperatures extraction is taken place, and linspace creates 200 values from low to high for calculation and plotting purposes.
  8. Moledular weight is calculated in a separate function that takes the specie name as input and returns the calculated molecular weight
    1. The function first splits the input into a cell array, and compares each element of the array to C, H, Ar, O, N, which are the only elements which the compounds in the file are composed of.
    2. Meanwhile, at every if condition, the next array element is converted to a number.
    3. If the number conversion returns true (>=1), then the current element's atomic weight is multiplied by that number. If not, then the weight is printed as is. Condition is left as ">=1" and NOT ">=2" for foolproofing purposes.
    4. Loop adds mol.wt. at every stage.
    5. Molecular weight is returned, which is then displayed in every execution.
  9. Now we read the 3 coefficients line, check positions of "E", as each coefficient contains E as the exponent indicator.
  10. 1 to E+x gives a coefficient, and E+x+1 goes to the next coefficient.
  11. The same is read and stored in 7 high and 7 low temperature coefficient variables.
  12. Next is a loop to calculate Cp, H and S. For temperatures above the local medium temperature, low temp. coefficients are used, and vice versa for temperatures above medium temperature.
  13. "mkdir" creates the folders, and specie name is passed to open folders with the respective specie name.
  14. Lasly, plotting is done and "saveas" is used to save the graphs as jpeg images with respective names, again with specie name passed as argument to saveas command.

Main Code Block:

R = 8.314; % Universal Gas Constant
f1 = fopen('THERMO.dat', 'r');

% Reading first line
fprintf('Data file title: %sn', fgetl(f1))

% Reading global temperatures line
% Splitting and storing into cell array, then converting to number
globaltemps = strsplit(fgetl(f1), ' ')
globallow = str2double(globaltemps{2})
globalmid = str2double(globaltemps{3})
globalhigh = str2double(globaltemps{4})

% Counting total number of lines traversed so far
count = 2;

% Traversing commented lines
for i = 1:3
    fgetl(f1);
    count = count + 1;
end

% Lines is the total number of lines in the document which we will use in the loop later on
lines = 0;
f2 = fopen('THERMO.dat', 'r');
while fgetl(f2) ~= -1
    lines = lines + 1;
end

% Below is the total number of lines after the commented lines in the DAT file
lines = lines - count;
fclose(f2);

% Variable Extraction and calculation starts here:
for i = 1:lines/4 % Every 4th line is an element's start, so we skip 4 lines in the counting
    
    % Starting off with the species line
    sline = strsplit(fgetl(f1), ' ');
    fprintf('Calculation for: %sn', sline{1})
    
    % Extracting Local low, medium and high Temperatures
    locallow = str2double(sline{length(sline)-3})
    localmed = str2double(sline{length(sline)-1})
    localhigh = str2double(sline{length(sline)-2})
    
    % Local temperature range
    T = linspace(locallow, localhigh, 200);
    
    % Molecular weight calculation
    % Mol. Wt. Calculated Separately in function "molwtcalc2"
    fprintf('Molecular Weight of %s is %fn', sline{1}, molwtcalc2(sline(1)))
    
    % Coefficient Extraction starts here
    dline1 = fgetl(f1);
    a = strfind(dline1, 'E'); % Changed to strfind from findstr later as it is faster
    dline2 = fgetl(f1);
    % b = findstr(dline2, 'E') % Since position of coefficients is the same in all lines, one line is enough
    dline3 = fgetl(f1);
    % c = findstr(dline3, 'E')
    
%   High temperature coefficients
    htc1 = str2double(dline1(1:a(1)+3));
    htc2 = str2double(dline1(a(1)+4:a(2)+3));
    htc3 = str2double(dline1(a(2)+4:a(3)+3));
    htc4 = str2double(dline1(a(3)+4:a(4)+3));
    htc5 = str2double(dline1(a(4)+4:a(5)+3));
    htc6 = str2double(dline2(1:a(1)+3));
    htc7 = str2double(dline2(a(1)+4:a(2)+3));
    
%   Low Temperature coefficients
    ltc1 = str2double(dline2(a(2)+4:a(3)+3));
    ltc2 = str2double(dline2(a(3)+4:a(4)+3));
    ltc3 = str2double(dline2(a(4)+4:a(5)+3));
    ltc4 = str2double(dline3(1:a(1)+3));
    ltc5 = str2double(dline3(a(1)+4:a(2)+3));
    ltc6 = str2double(dline3(a(2)+4:a(3)+3));
    ltc7 = str2double(dline3(a(3)+4:a(4)+3));
    
    % Calculation of Cp, H and S
    for k = 1:length(T)
        if T(k) > localmed % high temp coefficients usef for Temps > median temperature
            Cp(k) = R*(htc1 + (htc2*T(k)) + (htc3*(T(k))^2) + (htc4*(T(k))^3) + (htc5*(T(k))^4));
            H(k) = R*T(k)*(htc1 + ((htc2*T(k))/2) + ((htc3*(T(k))^2)/3) + ((htc4*(T(k))^3)/4) + ((htc5*(T(k))^4)/5) + (htc6/T(k)));
            S(k) = R*((htc1*log(T(k))) + (htc2*T(k)) + ((htc3*(T(k))^2)/2) + ((htc4*(T(k))^3)/3) + ((htc5*(T(k))^4)/4) + htc7);
        else % low temp coefficients usef for Temps < median temperature
            Cp(k) = R*(ltc1 + (ltc2*T(k)) + (ltc3*(T(k))^2) + (ltc4*(T(k))^3) + (ltc5*(T(k))^4));
            H(k) = R*T(k)*(ltc1 + ((ltc2*T(k))/2) + ((ltc3*(T(k))^2)/3) + ((ltc4*(T(k))^3)/4) + ((ltc5*(T(k))^4)/5) + (ltc6/T(k)));
            S(k) = R*((ltc1*log(T(k))) + (ltc2*T(k)) + ((ltc3*(T(k))^2)/2) + ((ltc4*(T(k))^3)/3) + ((ltc5*(T(k))^4)/4) + ltc7);
        end
    end
    
    % Creating directories
    mkdir(['Species Graph 1',sline{1}]) % Stored in separate directories IN a separate directory
    cd(['Species Graph 1',sline{1}])

    % Plot Specific Heat, Cp
    % a = i; Earlier, i used here to place in "figure(i)" to display
    % different figure numbers
    figure(1)
    plot(T, Cp, 'linewidth', 2, 'color', 'r')
    xlabel('Temperature (K)')
    ylabel('Specific Heat at Constant Pressure (J/KgK)')
    title(['Specific Heat vs Temperature for ', sline{1}])
    saveas(1, ['Specific Heat vs Temperature for ', sline{1}], 'jpeg')

    % Plot Enthalpy, H
    % b = i+53;
    figure(2)
    plot(T, H, 'linewidth', 2, 'color', 'b')
    xlabel('Temperature (K)')
    ylabel('Enthalpy (J)')
    title(['Enthalpy vs Temperature for ', sline{1}])
    saveas(2, ['Enthalpy vs Temperature for ', sline{1}], 'jpeg')
    
    % Plot Entropy, S
    % c = b+53;
    figure(3)
    plot(T, S, 'linewidth', 2, 'color', 'g')
    xlabel('Temperature (K)')
    ylabel('Entropy (J/K)')
    title(['Entropy vs Temperature for ', sline{1}])
    saveas(3, ['Entropy vs Temperature for ', sline{1}], 'jpeg')
    
    cd ..
    cd ..
    
    disp('________________________________________________________________________________________________');
    % Output window separator line for better viewing
end

fclose(f1);

Molecular Weight Function Code:

function [molwt] = molwtcalc2(specie)

  molwt = 0;
    elements = split(specie, "");
    for j = 2: length(elements)-1
        n = str2num(elements{j+1});
        if elements{j} == 'C'
            if n >= 1
                    molwt = molwt + (n*12);
            else
                    molwt = molwt + 12;
            end
        elseif elements{j} == 'H'
            if n >= 1
                molwt = molwt + (n*1);
            else
                molwt = molwt + 1;
            end
        elseif elements{j} == 'O'
            if n >= 1
                molwt = molwt + (n*16);
            else
                molwt = molwt + 16;
            end
        elseif elements{j} == 'N'
            if n >= 1
                molwt = molwt + (n*14);
            else
                molwt = molwt + 14;
            end
        elseif (elements{j} == 'A') && (elements{j+1} == 'R') % AR = 'A' and 'R' in 2 separate cell locations
            if n >= 1
                molwt = molwt + (n*40);
            else
                molwt = molwt + 40;
            end
        end
    end
    
    molwt;
end

Window Screenshots:

Plots:

  1. O2:


  2. N2:




  3. CO2:



Errors:

  1. Strsplit error: Loop had exceeded the last line of the file and the value of fgetl was '-1', which wasn't getting accepted into strsplit;

    Solution: Changed to "lines/4" as discussed in procedure for 53 species.

  2. Initial attempt at switch..case: "elements(j)" cannot be used as elements is a cell array

    Solution: 
    changed to curly braces "elements{j}". Later changed to if..elseif construct in favour of multiplication of atomic weights.

  3. Cell array input into fprintf: () used for cell array "sline"

    Solution: 
    Changed to "sline{1}".

  4. Plot command error: Accidentally putting linewidth value in quotes

    Solution: 
    removed quotes from number 2.

  5. Indices error in H equation:

    Solution: 
    Had forgotten the (k) in "T(k)". Corrected accordingly.

  6. cd error: Had forgotten to put "cd .." at the end of the loop to go back to the parent folder, hence it was constantly going deeper with every iteration until the directory name was too long.

    Solution: 
    Added "cd .." to return to previous directory.

Output Window (showing execution and molecular weight for all species):

Data file title: THERMO

globaltemps =

  1×4 cell array

  Columns 1 through 3

    {0×0 char}    {'300.000'}    {'1000.000'}

  Column 4

    {'5000.000'}


globallow =

   300


globalmid =

        1000


globalhigh =

        5000

Calculation for: O

locallow =

   200


localmed =

        1000


localhigh =

        3500

Molecular Weight of O is 16.000000
________________________________________________________________________________________________
Calculation for: O2

locallow =

   200


localmed =

        1000


localhigh =

        3500

Molecular Weight of O2 is 32.000000
________________________________________________________________________________________________
Calculation for: H

locallow =

   200


localmed =

        1000


localhigh =

        3500

Molecular Weight of H is 1.000000
________________________________________________________________________________________________
Calculation for: H2

locallow =

   200


localmed =

        1000


localhigh =

        3500

Molecular Weight of H2 is 2.000000
________________________________________________________________________________________________
Calculation for: OH

locallow =

   200


localmed =

        1000


localhigh =

        3500

Molecular Weight of OH is 17.000000
________________________________________________________________________________________________
Calculation for: H2O

locallow =

   200


localmed =

        1000


localhigh =

        3500

Molecular Weight of H2O is 18.000000
________________________________________________________________________________________________
Calculation for: HO2

locallow =

   200


localmed =

        1000


localhigh =

        3500

Molecular Weight of HO2 is 33.000000
________________________________________________________________________________________________
Calculation for: H2O2

locallow =

   200


localmed =

        1000


localhigh =

        3500

Molecular Weight of H2O2 is 34.000000
________________________________________________________________________________________________
Calculation for: C

locallow =

   200


localmed =

        1000


localhigh =

        3500

Molecular Weight of C is 12.000000
________________________________________________________________________________________________
Calculation for: CH

locallow =

   200


localmed =

        1000


localhigh =

        3500

Molecular Weight of CH is 13.000000
________________________________________________________________________________________________
Calculation for: CH2

locallow =

   200


localmed =

        1000


localhigh =

        3500

Molecular Weight of CH2 is 14.000000
________________________________________________________________________________________________
Calculation for: CH2(S)

locallow =

   200


localmed =

        1000


localhigh =

        3500

Molecular Weight of CH2(S) is 14.000000
________________________________________________________________________________________________
Calculation for: CH3

locallow =

   200


localmed =

        1000


localhigh =

        3500

Molecular Weight of CH3 is 15.000000
________________________________________________________________________________________________
Calculation for: CH4

locallow =

   200


localmed =

        1000


localhigh =

        3500

Molecular Weight of CH4 is 16.000000
________________________________________________________________________________________________
Calculation for: CO

locallow =

   200


localmed =

        1000


localhigh =

        3500

Molecular Weight of CO is 28.000000
________________________________________________________________________________________________
Calculation for: CO2

locallow =

   200


localmed =

        1000


localhigh =

        3500

Molecular Weight of CO2 is 44.000000
________________________________________________________________________________________________
Calculation for: HCO

locallow =

   200


localmed =

        1000


localhigh =

        3500

Molecular Weight of HCO is 29.000000
________________________________________________________________________________________________
Calculation for: CH2O

locallow =

   200


localmed =

        1000


localhigh =

        3500

Molecular Weight of CH2O is 30.000000
________________________________________________________________________________________________
Calculation for: CH2OH

locallow =

   200


localmed =

        1000


localhigh =

        3500

Molecular Weight of CH2OH is 31.000000
________________________________________________________________________________________________
Calculation for: CH3O

locallow =

   300


localmed =

        1000


localhigh =

        3000

Molecular Weight of CH3O is 31.000000
________________________________________________________________________________________________
Calculation for: CH3OH

locallow =

   200


localmed =

        1000


localhigh =

        3500

Molecular Weight of CH3OH is 32.000000
________________________________________________________________________________________________
Calculation for: C2H

locallow =

   200


localmed =

        1000


localhigh =

        3500

Molecular Weight of C2H is 25.000000
________________________________________________________________________________________________
Calculation for: C2H2

locallow =

   200


localmed =

        1000


localhigh =

        3500

Molecular Weight of C2H2 is 26.000000
________________________________________________________________________________________________
Calculation for: C2H3

locallow =

   200


localmed =

        1000


localhigh =

        3500

Molecular Weight of C2H3 is 27.000000
________________________________________________________________________________________________
Calculation for: C2H4

locallow =

   200


localmed =

        1000


localhigh =

        3500

Molecular Weight of C2H4 is 28.000000
________________________________________________________________________________________________
Calculation for: C2H5

locallow =

   200


localmed =

        1000


localhigh =

        3500

Molecular Weight of C2H5 is 29.000000
________________________________________________________________________________________________
Calculation for: C2H6

locallow =

   200


localmed =

        1000


localhigh =

        3500

Molecular Weight of C2H6 is 30.000000
________________________________________________________________________________________________
Calculation for: CH2CO

locallow =

   200


localmed =

        1000


localhigh =

        3500

Molecular Weight of CH2CO is 42.000000
________________________________________________________________________________________________
Calculation for: HCCO

locallow =

   300


localmed =

        1000


localhigh =

        4000

Molecular Weight of HCCO is 41.000000
________________________________________________________________________________________________
Calculation for: HCCOH

locallow =

   300


localmed =

        1000


localhigh =

        5000

Molecular Weight of HCCOH is 42.000000
________________________________________________________________________________________________
Calculation for: H2CN

locallow =

   300


localmed =

        1000


localhigh =

        4000

Molecular Weight of H2CN is 28.000000
________________________________________________________________________________________________
Calculation for: HCN

locallow =

   200


localmed =

        1000


localhigh =

        6000

Molecular Weight of HCN is 27.000000
________________________________________________________________________________________________
Calculation for: HNO

locallow =

   200


localmed =

        1000


localhigh =

        6000

Molecular Weight of HNO is 31.000000
________________________________________________________________________________________________
Calculation for: N

locallow =

   200


localmed =

        1000


localhigh =

        6000

Molecular Weight of N is 14.000000
________________________________________________________________________________________________
Calculation for: NNH

locallow =

   200


localmed =

        1000


localhigh =

        6000

Molecular Weight of NNH is 29.000000
________________________________________________________________________________________________
Calculation for: N2O

locallow =

   200


localmed =

        1000


localhigh =

        6000

Molecular Weight of N2O is 44.000000
________________________________________________________________________________________________
Calculation for: NH

locallow =

   200


localmed =

        1000


localhigh =

        6000

Molecular Weight of NH is 15.000000
________________________________________________________________________________________________
Calculation for: NH2

locallow =

   200


localmed =

        1000


localhigh =

        6000

Molecular Weight of NH2 is 16.000000
________________________________________________________________________________________________
Calculation for: NH3

locallow =

   200


localmed =

        1000


localhigh =

        6000

Molecular Weight of NH3 is 17.000000
________________________________________________________________________________________________
Calculation for: NO

locallow =

   200


localmed =

        1000


localhigh =

        6000

Molecular Weight of NO is 30.000000
________________________________________________________________________________________________
Calculation for: NO2

locallow =

   200


localmed =

        1000


localhigh =

        6000

Molecular Weight of NO2 is 46.000000
________________________________________________________________________________________________
Calculation for: HCNO

locallow =

   300


localmed =

        1382


localhigh =

        5000

Molecular Weight of HCNO is 43.000000
________________________________________________________________________________________________
Calculation for: HOCN

locallow =

   300


localmed =

        1368


localhigh =

        5000

Molecular Weight of HOCN is 43.000000
________________________________________________________________________________________________
Calculation for: HNCO

locallow =

   300


localmed =

        1478


localhigh =

        5000

Molecular Weight of HNCO is 43.000000
________________________________________________________________________________________________
Calculation for: NCO

locallow =

   200


localmed =

        1000


localhigh =

        6000

Molecular Weight of NCO is 42.000000
________________________________________________________________________________________________
Calculation for: CN

locallow =

   200


localmed =

        1000


localhigh =

        6000

Molecular Weight of CN is 26.000000
________________________________________________________________________________________________
Calculation for: HCNN

locallow =

   300


localmed =

        1000


localhigh =

        5000

Molecular Weight of HCNN is 41.000000
________________________________________________________________________________________________
Calculation for: N2

locallow =

   300


localmed =

        1000


localhigh =

        5000

Molecular Weight of N2 is 28.000000
________________________________________________________________________________________________
Calculation for: AR

locallow =

   300


localmed =

        1000


localhigh =

        5000

Molecular Weight of AR is 40.000000
________________________________________________________________________________________________
Calculation for: C3H8

locallow =

   300


localmed =

        1000


localhigh =

        5000

Molecular Weight of C3H8 is 44.000000
________________________________________________________________________________________________
Calculation for: C3H7

locallow =

   300


localmed =

        1000


localhigh =

        5000

Molecular Weight of C3H7 is 43.000000
________________________________________________________________________________________________
Calculation for: CH3CHO

locallow =

   200


localmed =

        1000


localhigh =

        6000

Molecular Weight of CH3CHO is 44.000000
________________________________________________________________________________________________
Calculation for: CH2CHO

locallow =

   300


localmed =

        1000


localhigh =

        5000

Molecular Weight of CH2CHO is 43.000000
________________________________________________________________________________________________
>> thermocodeDUMMY
Data file title: THERMO

globaltemps =

  1×4 cell array

  Columns 1 through 3

    {0×0 char}    {'300.000'}    {'1000.000'}

  Column 4

    {'5000.000'}


globallow =

   300


globalmid =

        1000


globalhigh =

        5000

Calculation for: O

locallow =

   200


localmed =

        1000


localhigh =

        3500

Molecular Weight of O is 16.000000
________________________________________________________________________________________________
Calculation for: O2

locallow =

   200


localmed =

        1000


localhigh =

        3500

Molecular Weight of O2 is 32.000000
________________________________________________________________________________________________
Calculation for: H

locallow =

   200


localmed =

        1000


localhigh =

        3500

Molecular Weight of H is 1.000000
________________________________________________________________________________________________
Calculation for: H2

locallow =

   200


localmed =

        1000


localhigh =

        3500

Molecular Weight of H2 is 2.000000
________________________________________________________________________________________________
Calculation for: OH

locallow =

   200


localmed =

        1000


localhigh =

        3500

Molecular Weight of OH is 17.000000
________________________________________________________________________________________________
Calculation for: H2O

locallow =

   200


localmed =

        1000


localhigh =

        3500

Molecular Weight of H2O is 18.000000
________________________________________________________________________________________________
Calculation for: HO2

locallow =

   200


localmed =

        1000


localhigh =

        3500

Molecular Weight of HO2 is 33.000000
________________________________________________________________________________________________
Calculation for: H2O2

locallow =

   200


localmed =

        1000


localhigh =

        3500

Molecular Weight of H2O2 is 34.000000
________________________________________________________________________________________________
Calculation for: C

locallow =

   200


localmed =

        1000


localhigh =

        3500

Molecular Weight of C is 12.000000
________________________________________________________________________________________________
Calculation for: CH

locallow =

   200


localmed =

        1000


localhigh =

        3500

Molecular Weight of CH is 13.000000
________________________________________________________________________________________________
Calculation for: CH2

locallow =

   200


localmed =

        1000


localhigh =

        3500

Molecular Weight of CH2 is 14.000000
________________________________________________________________________________________________
Calculation for: CH2(S)

locallow =

   200


localmed =

        1000


localhigh =

        3500

Molecular Weight of CH2(S) is 14.000000
________________________________________________________________________________________________
Calculation for: CH3

locallow =

   200


localmed =

        1000


localhigh =

        3500

Molecular Weight of CH3 is 15.000000
________________________________________________________________________________________________
Calculation for: CH4

locallow =

   200


localmed =

        1000


localhigh =

        3500

Molecular Weight of CH4 is 16.000000
________________________________________________________________________________________________
Calculation for: CO

locallow =

   200


localmed =

        1000


localhigh =

        3500

Molecular Weight of CO is 28.000000
________________________________________________________________________________________________
Calculation for: CO2

locallow =

   200


localmed =

        1000


localhigh =

        3500

Molecular Weight of CO2 is 44.000000
________________________________________________________________________________________________
Calculation for: HCO

locallow =

   200


localmed =

        1000


localhigh =

        3500

Molecular Weight of HCO is 29.000000
________________________________________________________________________________________________
Calculation for: CH2O

locallow =

   200


localmed =

        1000


localhigh =

        3500

Molecular Weight of CH2O is 30.000000
________________________________________________________________________________________________
Calculation for: CH2OH

locallow =

   200


localmed =

        1000


localhigh =

        3500

Molecular Weight of CH2OH is 31.000000
________________________________________________________________________________________________
Calculation for: CH3O

locallow =

   300


localmed =

        1000


localhigh =

        3000

Molecular Weight of CH3O is 31.000000
________________________________________________________________________________________________
Calculation for: CH3OH

locallow =

   200


localmed =

        1000


localhigh =

        3500

Molecular Weight of CH3OH is 32.000000
________________________________________________________________________________________________
Calculation for: C2H

locallow =

   200


localmed =

        1000


localhigh =

        3500

Molecular Weight of C2H is 25.000000
________________________________________________________________________________________________
Calculation for: C2H2

locallow =

   200


localmed =

        1000


localhigh =

        3500

Molecular Weight of C2H2 is 26.000000
________________________________________________________________________________________________
Calculation for: C2H3

locallow =

   200


localmed =

        1000


localhigh =

        3500

Molecular Weight of C2H3 is 27.000000
________________________________________________________________________________________________
Calculation for: C2H4

locallow =

   200


localmed =

        1000


localhigh =

        3500

Molecular Weight of C2H4 is 28.000000
________________________________________________________________________________________________
Calculation for: C2H5

locallow =

   200


localmed =

        1000


localhigh =

        3500

Molecular Weight of C2H5 is 29.000000
________________________________________________________________________________________________
Calculation for: C2H6

locallow =

   200


localmed =

        1000


localhigh =

        3500

Molecular Weight of C2H6 is 30.000000
________________________________________________________________________________________________
Calculation for: CH2CO

locallow =

   200


localmed =

        1000


localhigh =

        3500

Molecular Weight of CH2CO is 42.000000
________________________________________________________________________________________________
Calculation for: HCCO

locallow =

   300


localmed =

        1000


localhigh =

        4000

Molecular Weight of HCCO is 41.000000
________________________________________________________________________________________________
Calculation for: HCCOH

locallow =

   300


localmed =

        1000


localhigh =

        5000

Molecular Weight of HCCOH is 42.000000
________________________________________________________________________________________________
Calculation for: H2CN

locallow =

   300


localmed =

        1000


localhigh =

        4000

Molecular Weight of H2CN is 28.000000
________________________________________________________________________________________________
Calculation for: HCN

locallow =

   200


localmed =

        1000


localhigh =

        6000

Molecular Weight of HCN is 27.000000
________________________________________________________________________________________________
Calculation for: HNO

locallow =

   200


localmed =

        1000


localhigh =

        6000

Molecular Weight of HNO is 31.000000
________________________________________________________________________________________________
Calculation for: N

locallow =

   200


localmed =

        1000


localhigh =

        6000

Molecular Weight of N is 14.000000
________________________________________________________________________________________________
Calculation for: NNH

locallow =

   200


localmed =

        1000


localhigh =

        6000

Molecular Weight of NNH is 29.000000
________________________________________________________________________________________________
Calculation for: N2O

locallow =

   200


localmed =

        1000


localhigh =

        6000

Molecular Weight of N2O is 44.000000
________________________________________________________________________________________________
Calculation for: NH

locallow =

   200


localmed =

        1000


localhigh =

        6000

Molecular Weight of NH is 15.000000
________________________________________________________________________________________________
Calculation for: NH2

locallow =

   200


localmed =

        1000


localhigh =

        6000

Molecular Weight of NH2 is 16.000000
________________________________________________________________________________________________
Calculation for: NH3

locallow =

   200


localmed =

        1000


localhigh =

        6000

Molecular Weight of NH3 is 17.000000
________________________________________________________________________________________________
Calculation for: NO

locallow =

   200


localmed =

        1000


localhigh =

        6000

Molecular Weight of NO is 30.000000
________________________________________________________________________________________________
Calculation for: NO2

locallow =

   200


localmed =

        1000


localhigh =

        6000

Molecular Weight of NO2 is 46.000000
________________________________________________________________________________________________
Calculation for: HCNO

locallow =

   300


localmed =

        1382


localhigh =

        5000

Molecular Weight of HCNO is 43.000000
________________________________________________________________________________________________
Calculation for: HOCN

locallow =

   300


localmed =

        1368


localhigh =

        5000

Molecular Weight of HOCN is 43.000000
________________________________________________________________________________________________
Calculation for: HNCO

locallow =

   300


localmed =

        1478


localhigh =

        5000

Molecular Weight of HNCO is 43.000000
________________________________________________________________________________________________
Calculation for: NCO

locallow =

   200


localmed =

        1000


localhigh =

        6000

Molecular Weight of NCO is 42.000000
________________________________________________________________________________________________
Calculation for: CN

locallow =

   200


localmed =

        1000


localhigh =

        6000

Molecular Weight of CN is 26.000000
________________________________________________________________________________________________
Calculation for: HCNN

locallow =

   300


localmed =

        1000


localhigh =

        5000

Molecular Weight of HCNN is 41.000000
________________________________________________________________________________________________
Calculation for: N2

locallow =

   300


localmed =

        1000


localhigh =

        5000

Molecular Weight of N2 is 28.000000
________________________________________________________________________________________________
Calculation for: AR

locallow =

   300


localmed =

        1000


localhigh =

        5000

Molecular Weight of AR is 40.000000
________________________________________________________________________________________________
Calculation for: C3H8

locallow =

   300


localmed =

        1000


localhigh =

        5000

Molecular Weight of C3H8 is 44.000000
________________________________________________________________________________________________
Calculation for: C3H7

locallow =

   300


localmed =

        1000


localhigh =

        5000

Molecular Weight of C3H7 is 43.000000
________________________________________________________________________________________________
Calculation for: CH3CHO

locallow =

   200


localmed =

        1000


localhigh =

        6000

Molecular Weight of CH3CHO is 44.000000
________________________________________________________________________________________________
Calculation for: CH2CHO

locallow =

   300


localmed =

        1000


localhigh =

        5000

Molecular Weight of CH2CHO is 43.000000
________________________________________________________________________________________________
>> 

References:

  1. https://in.mathworks.com/matlabcentral/answers/154272-input-a-variable-into-a-plot-title
  2. https://stackoverflow.com/questions/2338392/matlab-quickie-test-if-text-file-is-empty
  3. https://in.mathworks.com/matlabcentral/answers/229602-what-is-the-syntax-for-do-while-loop-in-matlab
  4. https://in.mathworks.com/matlabcentral/answers/365239-help-with-splitting-a-string-into-a-character-array
  5. https://in.mathworks.com/help/matlab/ref/if.html
  6. https://in.mathworks.com/help/matlab/ref/switch.html
  7. https://in.mathworks.com/help/matlab/ref/saveas.html
  8. https://en.wikipedia.org/wiki/Enthalpy

Projects by Arjun Bhat

This project explores the simulation of the motion of a pendulum for the equation of damped vibration of a pendulum. Below is the equation (taken from "Challenges" page): The above equation is solved using ODE function, and then odeint is used to get an ar Read more

Project involves plotting an Otto Cycle graph in MATLAB The goal is to plot all strokes for a petrol operating by the otto cycle from intake, compression, power to exhaust, including both adiabatic curves. Description: The Otto Cycle is the idealised cycle that descr Read more

Objective: The project involves simulating a 2-joint robotic arm.   Code and Description: import math import matplotlib.pyplot as plt import numpy as nm # Lengths l1 = 1 l2 = 0.5 # Angles ang1 = nm.radians(nm.linspace(0, 90, 19)) ang2 = nm.radians Read more

Flow over bicycle in Python
Arjun Bhat · 2019-11-18 16:09:30

Objective: To calculate the drag force for various drag coefficient and velocity values for a certain geometry.   Introduction: Drag force is the force exerted by the air as the vehicle moves through it. The force exerted is directly proportional to the square Read more

The project aims at optimization of a stalagmite function and finding the global maxima. For this, we will be using the concept of genetic algorithm. Following are the steps used to optimise the function: Code the function given in a separate function code. This is Read more

Curve Fitting using MATLAB
Arjun Bhat · 2019-08-19 20:20:53

Project aims at finding the best fit curve for a given data and finding the error between the original and said curve. The data being used is that of Specific heat (Cp) vs Temeperature. Plot will be made to show variation of Cp with Temp first.  Code: % Data cp Read more

This project explores the simulation of the motion of a pendulum for the equation of damped vibration of a pendulum. Below is the equation (taken from "Challenges" page): An attempt is made to solve the above equation, and then call it using ode45 to get an array of Read more

Project involves plotting an Otto Cycle graph in MATLAB The goal is to plot all strokes for a petrol operating by the otto cycle from intake, compression, power to exhaust, including both adiabatic curves. Description: The Otto Cycle is the idealised cycle that descr Read more

Code and Description: The project involves simulating a 2-joint robotic arm. % Lengths l1 = 1; l2 = 0.5; % Angles ang1 = linspace (0, 90, 20); ang2 = linspace (0, 90, 20); count = 1; % loop for i = 1:length(ang1) ANG1 = ang1(i); for j = 1:length(ang2 Read more


Loading...

The End