hrap 0.1.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (37) hide show
  1. hrap-0.1.0/.gitignore +5 -0
  2. hrap-0.1.0/PKG-INFO +13 -0
  3. hrap-0.1.0/README.md +56 -0
  4. hrap-0.1.0/hrap/__init__.py +0 -0
  5. hrap-0.1.0/hrap/chamber.py +102 -0
  6. hrap-0.1.0/hrap/chem.py +635 -0
  7. hrap-0.1.0/hrap/core.py +345 -0
  8. hrap-0.1.0/hrap/examples/README.md +0 -0
  9. hrap-0.1.0/hrap/examples/nitrous_abs_star.py +5 -0
  10. hrap-0.1.0/hrap/examples/nitrous_plastisol.py +242 -0
  11. hrap-0.1.0/hrap/grain.py +127 -0
  12. hrap-0.1.0/hrap/gui/hrap.py +943 -0
  13. hrap-0.1.0/hrap/gui/themes.py +110 -0
  14. hrap-0.1.0/hrap/nozzle.py +106 -0
  15. hrap-0.1.0/hrap/resources/fonts/BubblegumSans-Regular.ttf +0 -0
  16. hrap-0.1.0/hrap/resources/fonts/BubblegumSans_OFL.txt +95 -0
  17. hrap-0.1.0/hrap/resources/fonts/Roboto-Regular.ttf +0 -0
  18. hrap-0.1.0/hrap/resources/fonts/Roboto_OFL.txt +93 -0
  19. hrap-0.1.0/hrap/resources/icon.ico +0 -0
  20. hrap-0.1.0/hrap/resources/icon_16.png +0 -0
  21. hrap-0.1.0/hrap/resources/icon_24.png +0 -0
  22. hrap-0.1.0/hrap/resources/icon_32.png +0 -0
  23. hrap-0.1.0/hrap/resources/icon_48.png +0 -0
  24. hrap-0.1.0/hrap/resources/propellant_configs/ABS.mat +0 -0
  25. hrap-0.1.0/hrap/resources/propellant_configs/Asphalt.mat +0 -0
  26. hrap-0.1.0/hrap/resources/propellant_configs/HDPE.mat +0 -0
  27. hrap-0.1.0/hrap/resources/propellant_configs/HTPB.mat +0 -0
  28. hrap-0.1.0/hrap/resources/propellant_configs/HTPB_Paraffin.mat +0 -0
  29. hrap-0.1.0/hrap/resources/propellant_configs/Metalized_Plastisol.mat +0 -0
  30. hrap-0.1.0/hrap/resources/propellant_configs/Paraffin.mat +0 -0
  31. hrap-0.1.0/hrap/resources/propellant_configs/Sorbitol.mat +0 -0
  32. hrap-0.1.0/hrap/resources/validation/hybrid_fire_7_26_23.csv +168 -0
  33. hrap-0.1.0/hrap/sat_nos.py +93 -0
  34. hrap-0.1.0/hrap/sdf.py +109 -0
  35. hrap-0.1.0/hrap/tank.py +254 -0
  36. hrap-0.1.0/hrap/units.py +60 -0
  37. hrap-0.1.0/pyproject.toml +34 -0
hrap-0.1.0/.gitignore ADDED
@@ -0,0 +1,5 @@
1
+ __pycache__/
2
+ results/
3
+ /dist/
4
+ *.egg-info/
5
+ hrap/ssts_thermochem.txt
hrap-0.1.0/PKG-INFO ADDED
@@ -0,0 +1,13 @@
1
+ Metadata-Version: 2.4
2
+ Name: hrap
3
+ Version: 0.1.0
4
+ Summary: HRAP is a versatile tool for simulation of hybrid rocket engines.
5
+ Project-URL: Homepage, https://github.com/rnickel1/HRAP_Source
6
+ Author: Drew Nickel, Thomas Scott
7
+ Requires-Python: >=3.10
8
+ Requires-Dist: dearpygui
9
+ Requires-Dist: dearpygui-ext
10
+ Requires-Dist: jax
11
+ Requires-Dist: jaxlib
12
+ Requires-Dist: numpy
13
+ Requires-Dist: scipy
hrap-0.1.0/README.md ADDED
@@ -0,0 +1,56 @@
1
+ ## User Installation Instructions (Windows/Linux/Mac)
2
+ First install Python https://www.python.org/downloads/.
3
+
4
+ Then open your terminal and execute:
5
+
6
+ ```
7
+ python -m pip install --upgrade pip
8
+
9
+ python -m pip install hrap
10
+ ```
11
+
12
+ To update hrap when new features become available, simply run
13
+
14
+ ```
15
+ python -m pip install --upgrade hrap
16
+ ```
17
+
18
+ To uninstall hrap,
19
+
20
+ ```
21
+ python -m pip uninstall hrap
22
+ ```
23
+
24
+ ## Running HRAP
25
+ To start the GUI, simply run the command from any directory:
26
+
27
+ ```
28
+ hrap
29
+ ```
30
+
31
+ If you are interested in advanced usage such as design optimization, uncertainty quantification, etc. then scripting with the Python interface is recommended.
32
+ See the "HRAP - Python/hrap/examples" directories for a few examples.
33
+
34
+ Coming soon: optimization and UQ examples
35
+
36
+ ## Advanced Usage
37
+ HRAP Python utilizes JAX for Just-In-Time (JIT) compilation, enabling much faster execution speeds that make the real-time GUI updates possible and facilitate speedy parameter studies.
38
+ The helper functions in HRAP minimize the technical knowledge of JAX and Python required to make modifications.
39
+ Still, a few
40
+
41
+ Coming soon: example on how to add a custom ???
42
+
43
+ ## Developer Installation Instructions (Windows/Linux/Mac)
44
+ This is only necessary if you wish to contribute to the official HRAP repository.
45
+ You can script your own custom functionality with the "user installation."
46
+ This is an alternative to "User Installation." Please uninstall hrap or use a new venv before switching to the "Developer Installation."
47
+
48
+ After cloning the repo,
49
+
50
+ ```
51
+ cd "HRAP_JAX/HRAP - Python/"
52
+
53
+ pip install -e ./
54
+ ```
55
+
56
+ You can now run the GUI as usual. Your local modifications to the hrap code will be reflected.
File without changes
@@ -0,0 +1,102 @@
1
+ from hrap.core import store_x, make_part
2
+
3
+ import jax
4
+ import jax.numpy as jnp
5
+ from jax.lax import cond
6
+
7
+ def d_chamber(s, x, xmap):
8
+ Pc = x[xmap['cmbr_P']] # Combustion chamber pressure
9
+ grn_mdot = x[xmap['grn_mdot']] # Rate of grain mass being consumed
10
+ inj_mdot = x[xmap['tnk_mdot_inj']] # Rate of tank propellants being consumed
11
+ noz_mdot = x[xmap['noz_mdot']] # Rate of mass exiting through nozzle
12
+ m_g = x[xmap['cmbr_m_g']] # Mass of gas currently in chamber
13
+ V = x[xmap['cmbr_V0']] - x[xmap['grn_V']] # Gas volume in chamber
14
+ dV = x[xmap['grn_Vdot']] # Gas volume in chamber derivative
15
+ OF = x[xmap['cmbr_OF']] # O/F ratio, set by grain file
16
+
17
+ # Chamber stored mass derivative
18
+ mdot_g = grn_mdot + inj_mdot - noz_mdot
19
+ mdot_g = cond((m_g <= 0.0) & (mdot_g < 0.0), lambda val: 0.0, lambda val: val, mdot_g)
20
+
21
+ # Chamber pressure derivative
22
+ Pdot = Pc*(mdot_g/m_g - dV/V)
23
+ Pdot = cond(((Pc <= s['Pa']) & (Pdot < 0.0)) | (m_g <= 0.0), lambda val: 0.0, lambda val: val, Pdot)
24
+
25
+ # Get chamber properties and update cstar
26
+ # interp_point = jnp.array([[OF, Pc]])
27
+ # TODO: Need an error if out of bounds?
28
+ ig = s['chem_interp_k'].grid # interp grid
29
+ ip = jnp.array([[OF, Pc]]) # interp point
30
+ for i in range(2):
31
+ ip = ip.at[:,i].set(jnp.minimum(jnp.maximum(ip[:,i], ig[i][0]), ig[i][-1]))
32
+ k = s['chem_interp_k'](ip)[0]
33
+ M = s['chem_interp_M'](ip)[0]
34
+ T = s['chem_interp_T'](ip)[0]
35
+ # jax.debug.print('cmbr, k={a}, M={b}, T={c} from OF={d}, Pc={e}', a=k, b=M, c=T, d=OF, e=Pc)
36
+
37
+ R = 8314.5 / M
38
+ rho = Pc/(R * T)
39
+ cstar = s['cmbr_cstar_eff']*jnp.sqrt((R*T)/(k*(2/(k+1))**((k+1)/(k-1))))
40
+
41
+ # Store derivatives
42
+ x = store_x(x, xmap, cmbr_mdot_g=mdot_g, cmbr_Pdot=Pdot, cmbr_k=k, cmbr_T=T, cmbr_cstar=cstar)
43
+
44
+ return x
45
+
46
+ # Preprocessing
47
+ def p_chamber(s, x0, xmap):
48
+ V0 = x0[xmap['cmbr_V0']]
49
+
50
+ V0 = cond(V0 == 0.0, lambda Va, Vb: Vb, lambda Va, Vb: Va, V0, s['grn_L']*(jnp.pi/4*s['grn_OD']**2))
51
+ m_g0 = (101e3*29/8314/294) * V0 # p = rho R T
52
+
53
+ x0 = store_x(x0, xmap, cmbr_V0=V0, cmbr_m_g=m_g0)
54
+
55
+ return x0
56
+
57
+ def u_chamber(s, x, xmap):
58
+ # Limit stored and gas and pressure to reasonable values
59
+ x = store_x(x, xmap,
60
+ cmbr_m_g = jnp.maximum(x[xmap['cmbr_m_g']], 0.0),
61
+ cmbr_P = jnp.maximum(x[xmap['cmbr_P']], s['Pa']),
62
+ )
63
+
64
+ return x
65
+
66
+ def make_chamber(**kwargs):
67
+ return make_part(
68
+ # Default static parameters
69
+ s = {
70
+ 'cstar_eff': 1.0,
71
+ },
72
+
73
+ # Default initial variables
74
+ x = {
75
+ 'V0': 0.0, # Empty volume, doesn't change after initialization
76
+
77
+ 'P': 101e3,
78
+ 'm_g': 1E-3,
79
+
80
+ # Calculated variables
81
+ 'k': 0.0,
82
+ 'T': 0.0,
83
+ 'cstar': 0.0,
84
+ 'OF': 0.0, # Handled by grain file
85
+ },
86
+
87
+ # Required and integrated variables
88
+ req_s = [],
89
+ req_x = [],
90
+
91
+ # State name to derivative name for integrated variables
92
+ dx = { 'P': 'Pdot', 'm_g': 'mdot_g' } ,
93
+
94
+ # Designation and associated functions
95
+ typename = 'cmbr',
96
+ fpreprs = p_chamber,
97
+ fderiv = d_chamber,
98
+ fupdate = u_chamber,
99
+
100
+ # The user-specified s or x entries
101
+ **kwargs,
102
+ )