An open API service indexing awesome lists of open source software.

https://github.com/xrsrke/exex

Experiment codebase for chemchem package
https://github.com/xrsrke/exex

chemistry chemistry-solver general-chemistry python

Last synced: 7 months ago
JSON representation

Experiment codebase for chemchem package

Awesome Lists containing this project

README

          

exex
================

This file will become your README and also the index of your
documentation.

## Install

``` sh
pip install exex
```

``` python
C2 = Gas('C2')
```

``` python
O2 = Gas('O2')
```

``` python
CO2 = Gas('CO2')
```

``` python
r = Reaction(reactants=[Gas('C2'), Gas('O2')], products=[Gas('CO2')])
```

``` python
r.__dict__
```

{'reaction': ,
'reactants': [exex.gas.core.Gas(formula='C₂'),
exex.gas.core.Gas(formula='O₂')],
'products': [exex.gas.core.Gas(formula='C₁O₂')],
'formula': '1C₂ + 1O₂ --> 1C₁O₂',
'system': ,
'environment': }

``` python
CO2.get_system()
```

``` python
r.system.__dict__
```

{'universe': None,
'current_time': None,
'highest_time': None,
'reactions': [exex.reaction.core.Reaction(formula='1C₂ + 1O₂ --> 1C₁O₂')],
'_subscribers': {},
'idx_reaction': None}

``` python
r
```

exex.reaction.core.Reaction(formula='1C₂ + 1O₂ --> 1C₁O₂')

``` python
CO2.properties
```

{'mass': ,
'mole': ,
'pressure': ,
'volume': ,
'temperature': ,
'ideal_gas_constant': ,
'is_ideal_gas': }

``` python
CO2.laws['mass_mole_ratio'].__dict__
```

{'compound': exex.gas.core.Gas(formula='C₁O₂'),
'properties': [{'object': exex.core.Mass}, {'object': exex.core.Mole}]}

``` python
from exex.utils import camel_to_snake
```

``` python
camel2snake(CO2.__class__.__name__)
```

'gas'

``` python
C2.snake_name
```

'C2'

``` python
reactants = [C2, O2]
```

``` python
dic = {}
```

``` python
C2.formula
```

'C₂'

``` python
for reactant in reactants:
dic[reactant.snake_name] = reactant
```

``` python
dic
```

{'C2': exex.gas.core.Gas(formula='C₂'), 'O2': exex.gas.core.Gas(formula='O₂')}

``` python
C2
```

exex.gas.core.Gas(formula='C₂')

``` python
C2.__dict__
```

{'properties': {'mass': ,
'mole': ,
'pressure': ,
'volume': ,
'temperature': ,
'ideal_gas_constant': ,
'is_ideal_gas': },
'laws': {'mass_mole_ratio': ,
'boyle_law': ,
'charles_law': ,
'avogadro_law': ,
'ideal_gas_law': },
'time': None,
'system': ,
'elements': [,
],
'formula': 'C₂',
'coefficient': 1,
'occurences': {'C': 2}}

``` python
C2.formula
```

'C₂'

``` python
r.reaction.__dict__
```

{'reactants': [exex.gas.core.Gas(formula='C₂'),
exex.gas.core.Gas(formula='O₂')],
'products': [exex.gas.core.Gas(formula='C₁O₂')],
'compounds': [exex.gas.core.Gas(formula='C₂'),
exex.gas.core.Gas(formula='O₂'),
exex.gas.core.Gas(formula='C₁O₂')],
'reactant_formulas': ['C₂', 'O₂'],
'product_formulas': ['C₁O₂'],
'formula': '1C₂ + 1O₂ --> 1C₁O₂',
'coefficients': {'C₂': 1, 'O₂': 1, 'C₁O₂': 1},
'constituents': ['C₂', 'O₂', 'C₁O₂'],
'reactant_occurences': {'C': 2, 'O': 2},
'product_occurences': {'C': 1, 'O': 2},
'is_balanced': False}

``` python
from chemlib import Reaction, Compound
```

``` python
Reaction(reactants=[Compound('CO2')], products=[]).__dict__
```

{'reactants': [],
'products': [],
'compounds': [],
'reactant_formulas': ['C₁O₂'],
'product_formulas': [],
'formula': '1C₁O₂ --> ',
'coefficients': {'C₁O₂': 1},
'constituents': ['C₁O₂'],
'reactant_occurences': {'C': 1, 'O': 2},
'product_occurences': {},
'is_balanced': False}