SkillAgentSearch skills...

KiThe

collection of RUST structures and functions useful for chemical kinetics, chemical thermodynamics, combustion, heat and mass transfer, shock tubes and so on and so far. Work in progress. Advices and contributions will be appreciated

Install / Use

/learn @Gleb-Zaslavsky/KiThe
About this skill

Quality Score

0/100

Supported Platforms

Universal

README

[TOC]

KiThe

This is a package of structures, functions and databases useful for such areas as chemical thermodynamics, chemical kinetics, as well as modeling of chemical reactors, combustion, processes in shock tubes and rocket engines, propulsion.

PROJECT NEWS: Experimental kinetics pipeline (with GUI) added

Content

Features

When install as library:

  • Chemical kinetics
    • crate is equipped with a libraries of kinetic parameters of chemical reactions obtained as a result of parsing publicly available databases;
    • searching inside local kinetic libraries by reagents, products, etc.
    • parsing reaction equations into a list of substances;
    • parsing reaction equations into a stoichiometric matrix, matrix of coefficients of direct reactions and matrix of coefficients of reverse reactions, matrix of degrees of concentration for the kinetic function;
    • calculation of atomic composition, molar masses and matrix of atomic composition;
    • Automatic (for found in libs reactions) and by function call constucting of kinetic functions of all main types (elemntary, fall-off, troe, etc) - both rust functions and symbolic expressions;
    • Automatic chemical mechanism constructor (say you have some reagents and want to find all possible reactions between original species and all their products)
  • Thermodynamics
    • many libraries on board with thermodynamics and transport properties (NASA, NASA-CEA, NIST, Aramco transport, etc.) and handlers for them;
    • search substances thermodynamics and heat-mass transfer data through all libraries with storing of data in a structure;
    • Calculaton of Gibbs free energy of a given mixure of substances (numerical result at given T, P, concentration) and symbolic Gibbs free energy of a given mixure of substances (symbolic result at given T, P, concentration).
    • automatic NIST parser for thermochemical data;
    • CHEMICAL EQUILIBRIUM calculation
  • Gaseos combustion/Plug-flow steady-state 1D boundary value problem.
  • IVP problem for multiple solid state kinetic models with constant or linear increasing temperature
  • condended phase combustion IVP problem (under development)
  • Experimental Kinetics - data processing pipeline for Thermogravimetric Analysis TGA
    • raw data manupulations via Polars crate
    • smothing and filtering: Hampel/MAD, savitzky–golay, LOWESS, splines
    • Kinetyc methods - - Friedman, - Ozawa-Flinn-Wall (OFW), - Kissinger-Akahira-Sunose (KAS), Starink, Vyazovkin

When install as executable: CLI instrument to solve some of the heat-mass transfer, combustion, chemical engeneering problems. Now available:

  • BVP solver for gas phase steady-state combustion/plug-flow with constant mass velocity BVP problem
  • IVP problem for multiple solid state kinetic models with constant or linear increasing temperature.

pretty GUI menues:

* Main menu
* Menu for gas phase steady-state combustion/plug-flow with constant mass velocity BVP problem;
* Chemical kinetics menu: searching reactions in kinetics libraries, kinetic paramters display;
* Thermodynamics menu: Cp, dH, dS and Cp = Cp(T) polynoms for many substances;
* Transport properies: Diffusion, viscosity, thermal condusctivity for many substances;
* solid state kinetics models
* Solid GUI for Thermogravimetric Analysis suite:1) window for columns manipulations, filtering, scaling, filtering and smoothing,2) window for Table operations 3) window to create and redact plots (almost publishing level) 

Kinetics

  • parse reaction equations into a list of substances
  • parse reaction equations into a stoichiometric matrix, matrix of coefficients of direct reactions and matrix of coefficients of reverse reactions, matrix of degrees of concentration for the kinetic function,
  • calculate of atomic composition, molar masses and matrix of atomic composition.

Let us observe the main structure realizing that features

pub struct StoichAnalyzer {
    pub reactions: Vec<String>, //a vector of reactions
    pub groups: Option<HashMap<String, HashMap<String, usize>>>, // Chemical formulae may contain spectial names for chemical groupls i.e. groups of atoms, e.g. Me (methyl) group, which is converted into {"C":1, "H":3}
    pub substances: Vec<String>, // a vector of substances
    pub stecheo_matrx: Vec<Vec<f64>>, //  a vector of vectors of stoichiometric coefficients in each reaction
    pub stecheo_reags: Vec<Vec<f64>>, //  a vector of vectors of stoichiometric coefficients of reactants in each reaction
    pub stecheo_prods: Vec<Vec<f64>>, //  a vector of vectors of stoichiometric coefficients of products in each reaction
    pub G_matrix_reag: Vec<Vec<f64>>,// matrix of powers of concentrations for constructng kinetic equation for forward reaction 
    pub G_matrix_prod: Vec<Vec<f64>>,// matrix of powers of concentrations for constructng kinetic equation for reverse reaction 
    pub matrix_of_elements: Option<DMatrix<f64>>,// matrix of elemental composition
    pub vec_of_molmasses: Option<Vec<f64>>,// vector of molecular masses
}

usage

use KiThe::Kinetics::stoichiometry_analyzer::StoichAnalyzer;
let mut  StoichAnalyzer_instance = StoichAnalyzer::new();
let reactions_: Vec<&str> = vec!["A=2BM)", "B=>A + 3C_DUP", "2B+A=D**0.5"];
let reaction = reactions_.iter().map(|s| s.to_string()).collect();
 StoichAnalyzer_instance.reactions = reaction;
 StoichAnalyzer_instance.search_substances();
 StoichAnalyzer_instance.analyse_reactions();
          
let stecheo_matrx =  StoichAnalyzer_instance.stecheo_matrx;

let result = [
                [-1.0, 2.0, 0.0, 0.0],
                [1.0, -1.0, 3.0, 0.0],
                [-1.0, -2.0, 0.0, 1.0],
            ];
let result: Vec<Vec<f64>> = result.iter().map(|row| row.to_vec()).collect();
assert_eq!(stecheo_matrx, result);
println!("substances: {:?}", StoichAnalyzer_instance.substances);
println!("stecheo_matrx {:?}", stecheo_matrx);
  • Calculation of atomic composition, molar masses and matrix of atomic composition. We can use struct StoichAnalyzer or just use the more low-level functions
use KiThe::Kinetics::molmass::{calculate_molar_mass, parse_formula, calculate_molar_mass_of_vector_of_subs,
create_elem_composition_matrix};
let formula = "C6H8O6";
let (molar_mass, element_composition) = calculate_molar_mass(formula.to_string(), None); 
println!("Element counts: {:?}", element_composition);
println!("Molar mass: {:?} g/mol", molar_mass);
           
 let formula = "Na(NO3)2".to_string();
 let atomic_composition = parse_formula(formula, None);
 println!("{:?}", atomic_composition);


 let vec_of_formulae = vec!["H2O", "NaCl", "C6H8O6", "Ca(NO3)2"];
 let expected_molar_masses = vec![18.01528, 58.44316, 176.12, 164.093];
 let (matrix, vec_of_formulae) = create_elem_composition_matrix(vec_of_formulae, None);
   
for (i, &expected_molar_mass) in expected_molar_masses.iter().enumerate() {
               println!("molar mass: {:?} g/mol", calculated_molar_masses[i]);
               assert!((calculated_molar_masses[i] - expected_molar_mass).abs() < 1e-2);
}

let vec_of_formulae = vec!["H2O", "NaCl", "C3H8", "CH4"]; // 5 elements
let matrix = create_elem_composition_matrix(vec_of_formulae, None);
println!("{}", matrix);
  • crate is equipped with a libraries of kinetic parameters of chemical reactions obtained as a result of parsing publicly available databases, so you can view all libraries and all reactions in every library of kinetic DB, search reactions by substances and so on. Most important methods below
use KiThe::Kinetics::kinetics_lib_api::KineticData;
let mut kin_instance = KineticData::new();
            // collecting reaction data for library name lib
let lib = "NUIG";

kin_instance.open_json_files(lib);
            // veiew all reactions in library
kin_instance.print_all_reactions();
      
let reaction1 = kin_instance.search_reactdata_by_reaction_id("1");
println!("reaction1: {:?}", reaction1);
            // search reactions by substances 
kin_instance.search_reaction_by_reagents_and_products((vec!["CO".to_string()])  );
println!("reactions where CO is product: {:?}", kin_instance.FoundReactionsByProducts);
println!("reactions where CO is reagent: {:?}", kin_instance.FoundReactionsByReagents);

Kinetic data (Arrhenius parameters, etc) are parsed into stuctures

pub struct ReactionData {
    #[serde(rename = "type")]
    reaction_type: ReactionType,
    eq: String,
    pub react: Option<HashMap<String, f64>>,
    #[serde(flatten)]
    data: ReactionKinetics,
}

where ReactionType is enum for concrete type of reaction (elementary, fall-off, etc)

  • The module is automatic chemical mechanism constructor and takes as input the name of the library and the vector of substances and then produces the following data:
  1. all reactions of starting substances with each other, and all reactions of all their possible products with each other and with original substances.
  2. HashMap with kinetic data of all found reactions
use crate::Kinetics::mechfinder_api::Mechanism_search;
let mut mech_search = Mechanism_search::new(
                vec!["O".to_string(), "NH3".to_string(), "NO".to_string()], // what to search
                "NUIG".to_string(), // library name
            );
    
let (mechanism, reactants, vec_of_reactions) = mech_search.mechfinder_api();
println!("mechanism (reaction ID's) : {:?}", mechanism);
println!("reactants: {:?}", reactants);
println!("reaction eq's: {:?}", vec_of_reactions);
println!("vector of ReactionData structs with parsed data: {:#?}", mech_search.reactdata);

The most general approach is to use stuct KinData whin

View on GitHub
GitHub Stars13
CategoryDevelopment
Updated13h ago
Forks0

Languages

Rust

Security Score

80/100

Audited on Mar 26, 2026

No findings