Skip to main content

Library to automate analyzes in CEA NASA - Under development

Project description

Chemical Equilibrium With Application in Python - CEApy

Version: 1.0.5 (Under development), December 26, 2022

Short Description: Python library that automates analysis of rocket problems in
CEA-NASA, which for now only works on Windows.

Author: Julio C. R. Machado
Undergraduate student in the last period of the aerospace engineering course
at Federal University of Maranhão - Brazil.

Emails: julioromac@outlok.com, machado.juliocr@gmail.com, machado.julio@discente.ufma.br

Install:

pip install CEApy

Long Description:

    The library was developed to be embedded in other libraries, allowing automatic analysis
of the combustion process in rocket engine chambers. In its first version, it is possible to
analyze all combinations of compounds available in the thermodynamic library of CEA, which h
as a method called search_specie to search for all available chemical species.
    The library works by taking the parameters passed by the user through the settings, input
_propellants, input_parameters and output_parameters methods, and creating the input .inp fil
e, for subsequent execution of the fortran code developed by (Mcbride and Gordon, 1994.) For 
now only available on Windows by using the CEA2.exe executable and not the cea.f code. After 
execution, the library takes the desired parameters and exports the data in a   Pandas datafr
ame through the get_results method.
    For now, only rocket problems are available in the library, and methods that allow analyz
ing new specific mixtures by the number of atoms and their junction have not yet been created.
Methods that allow inserting, omitting or selecting species are not yet available, as well as
the option trace specie values and the parameters of Champman-Jouquet Detonation. These featu
res will be implemented in future versions.

           Methods

importing:

from CEApy import CEA

Methods Available:

combustion = CEA("My_first_Analysis")
combustion.search_specie()
combustion.show_all_species()
combustion.settings()
combustion.input_propellants()
combustion.input_parameters()
combustion.output_parameters()
combustion.show_inp_file()
combustion.run()
combustion.get_results()
combustion.show_out_file()
combustion.get_simulation_file()
combustion.remove_analysis_file()

search_specie

def search_specie(self, words):

- words: Specie to be searched

show_all_species

def show_all_species(self):

- Show all species in  the thermodynamical data of CEA

settings

def settings(self, frozen='yes', freezing_point='exit', 
             equilibrium='yes', short='yes', transport='yes'):

- frozen: enable or disable freeze condition, 'yes' or 'no'

- freezing_point: can be 'combustor' or 1, 'throat' or 2, 'exit' or 3,
or it can be an integer equal to or greater than 1. For better understanding,
see (McBride and Gordon, 1994) and (McBride and Gordon, 1996 ).

- equilibrium: enable or disable equilibrium condition, 'yes' or 'no'

- short: enable or disable short condition in the output file .out 'yes' or 'no'

- transport: enable or disable transport properties in the CEA analysis

input_propellants

def input_propellants(self, oxid=None, fuel=None):

- oxid: should be a list like: oxid=[oxid1,oxid2]
      oxid1 = [name,massfraction,temperature]
      name: name of propellant, massfraction: mas fraction of propellant (0 to 100),
      temperature: temperature of propellant in Kelvin.

- example of two oxids:
      oxid1 = ['O2(L)',50,54.36], oxid2 = ['N2O4(L)',50,298.15]
      oxid = [['O2(L)',50,54.36],['N2O4(L)',50,298.15]]
        if one:
      oxid = [['N2O4(L)',50,298.15]]
- fuel: fill in the same way as the oxidizer.

input_parameters

def input_parameters(self, combustion_temp=3800, chamber_pressure=None, acat=None, sub_aeat=None,
                     sup_aeat=None, pipe=None, of_ratio=None, chem_ratio=None,
                     phi_ratio=None, fbyw_ratio=None):

- Parameters must be a list, lik: sup_aeat = [10,20,150], of = [1,2,3,5]
if one: sup_aeat = [100], of = [3]
- fbyw: fuel by weight ratio, for better undertanding of parameters, see
McBride and Gordon, 1994) and (McBride and Gordon, 1996 ).
- acat: contraction ratio from stagnation values to throat
- sub_aeat: subsonic expansion ratio
- sup_aeat: supersonic expansion ratio

- example:
    CEA.input_parameters(chamber_pressure=[10],sup_aeat=[10,20],of_ratio=[1,2,3])

output_parameters

def output_parameters(self, user_outputs):

- user_outputs: Must be a string 'all' to evaluate all available output parameters, 
or a list of parameters, like: ['isp','cf','gam','mach','pipe']

List of output parameters available: 
output_list = [
'p', 't', 'rho', 'h', 'u', 'g', 's', 'm', 'mw', 'cp', 'gam', 'son',  # thermo prop
'pipe', 'mach', 'aeat', 'cf', 'ivac', 'isp',  # rocket performance
'vis', 'cond', 'condfz', 'pran',  'pranfz',  # transport properties
'%f', 'o/f', 'phi,eq.ratio', 'r,eq.ratio']  # fuel-oxidant mixture parameters

    For a better understanding of all parameters, see McBride and Gordon, 1994) and
(McBride and Gordon, 1996 ).

show_inp_file

def show_inp_file(self, type_f='logical'):

type_f: if 'logical': it shows the file being made by the code.
        if 'file': it shows the file written in the folder where
        the analysis is done, if it exists.

run

def run(self):

- Runs the CEA analysis

get_results

def get_results(self, column_names='all', condition=3):

- Returns the CEA simulation results, the parameters that were
defined in the output_parameters method
Column names: Must be a string 'all' to returns all available output parameters, 
or a list of parameters, like: ['isp','cf','gam','mach','pipe']

condition: Is the parameter that says which lines should be skipped.

    For example if condition = 3 and the results have 9 lines, the method will return 
lines 3, 6, 9. If condition = 3 and the results have 14 lines, the method will 
return lines 3, 6, 9 and 12. If condition = 4 and the results have 14 lines, the
method will return lines 4, 8 and 12. This parameter is important to get only results
that are of interest in certain analyses. for example, evaluating a range of
o/f = [1,2,3,4], the method will return all results in the combustor (1), throat (2)
and exit (3) section of all o/f considered. To get only the results in the output,
for example, make:
    
    condition =3 (this is the default).

    Most of the time it is difficult to evaluate the results, so it is better to get
all the available results, visualize and evaluate later. To get all results do:
    
    condition = 'all'

show_out_file

def show_out_file(self):

Show the output file '.out' after executing the run method

get_simulation_file

def get_simulation_file(self, type_file='out'):

Returns the file as a string for later saving in a specified folder.

- type_file = 'inp': returns the .inp file
- type_file = 'out': returns the .out file

remove_analysis_file

def remove_analysis_file(self, name=None):

- Delete the analysis file from the folder

- Always indicated after completing the analyzes and saving the relevant
files in the working folder.

observations:

1 - To save data, To save data, such as simulation results, images, or .inp and
.out files, the absolute path of the folder must be passed, for example:
C:/users/user/desktop/file.csv
not: 'file .csv'.
Otherwise the files will be saved in the library installation folder.

2 - In case of doubt or error in the results, or empty results, it is always
good to look at the output file name of the analysis.out and see if there are
errors, through the show_out_file method.

EXAMPLE:

from CEApy import CEA
import matplotlib.pyplot as plt

combustion = CEA("My_first_Analysis")

combustion.settings() # adding settings
# adding propellants
combustion.input_propellants(oxid=[['O2(L)', 100, 90.17]], fuel=[['RP-1', 100, 298.15]])
# adding input parameters
combustion.input_parameters(sup_aeat=[200], chamber_pressure=[10],
                            of_ratio=[0.5, 1, 2, 3])
# adding output parameters
combustion.output_parameters(user_outputs=['isp', 'cf', 'o/f'])
# running analyses 
combustion.run()
# getting results
df = combustion.get_results()
# plotting o/f x isp
df['isp'] = df['isp']/9.81
print(df)
plt.plot(df['o/f'], df['isp'])
plt.title('O/F x Isp (s), sup_aeat=200, pc = 10 bar')
plt.xlabel('O/F')
plt.ylabel('Isp (s)')
plt.legend('isp')
plt.show()
# getting output file to save if necessary
strings = combustion.get_simulation_file('out')
# deleting analysis files
combustion.remove_analysis_file()

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

CEApy-1.0.5.tar.gz (1.4 MB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

CEApy-1.0.5-py3-none-any.whl (1.4 MB view details)

Uploaded Python 3

File details

Details for the file CEApy-1.0.5.tar.gz.

File metadata

  • Download URL: CEApy-1.0.5.tar.gz
  • Upload date:
  • Size: 1.4 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.11.1

File hashes

Hashes for CEApy-1.0.5.tar.gz
Algorithm Hash digest
SHA256 71381c15471df520f648cb2d7fb7ee9deb273b6c29401bf9409e51b20f88eb20
MD5 2f4785b9af11f9eb76b3e1ec1f5b60d5
BLAKE2b-256 3355847fc2a113bbad2c9d328aa414f96e0f4e8cae725fe61def9f0e2dda735f

See more details on using hashes here.

File details

Details for the file CEApy-1.0.5-py3-none-any.whl.

File metadata

  • Download URL: CEApy-1.0.5-py3-none-any.whl
  • Upload date:
  • Size: 1.4 MB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.11.1

File hashes

Hashes for CEApy-1.0.5-py3-none-any.whl
Algorithm Hash digest
SHA256 4acabad5963cb6d696e890f9992972f3865bc852afae7416d14a085ca9b282e6
MD5 a4dbfa1e4a62cb8bcad2b561e9317934
BLAKE2b-256 0962e32e5222c6b4fef0ea0afc50e87ab2dc0340a14e976f86bb561b74db7307

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page