Skip to content

Commit

Permalink
inertiatesting
Browse files Browse the repository at this point in the history
  • Loading branch information
tbhakhri committed Nov 5, 2022
1 parent 0367cc1 commit 3dccd0e
Show file tree
Hide file tree
Showing 2 changed files with 115 additions and 2 deletions.
108 changes: 107 additions & 1 deletion tests/testing.ipynb → testing.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -336,6 +336,112 @@
"plt.plot(x, y)"
]
},
{
"cell_type": "code",
"execution_count": 3,
"metadata": {},
"outputs": [],
"source": [
"from rocketpy import Fluid\n",
"import numpy as np"
]
},
{
"cell_type": "code",
"execution_count": 10,
"metadata": {},
"outputs": [],
"source": [
"lox = Fluid(name = \"LOx\", density = 1141, quality = 1.0) #Placeholder quality value\n",
"n2 = Fluid(name = \"Nitrogen Gas\", density = 51.75, quality = 1.0) #Placeholder quality value; density value may be estimate\n",
"initial_liquid_mass = 5\n",
"initial_gas_mass = .1\n",
"liquid_mass_flow_rate_in = .1\n",
"gas_mass_flow_rate_in = .01\n",
"liquid_mass_flow_rate_out = .2\n",
"gas_mass_flow_rate_out = .02\n",
"\n",
"r = 1\n",
"alv = lambda x: (initial_liquid_mass + (liquid_mass_flow_rate_in - liquid_mass_flow_rate_out) * x) / lox.density\n",
"alh = lambda x: alv(x) / (np.pi)\n",
"m = lambda x: (initial_liquid_mass + (liquid_mass_flow_rate_in - liquid_mass_flow_rate_out) * x) + \\\n",
" (initial_gas_mass + (gas_mass_flow_rate_in - gas_mass_flow_rate_out) * x)\n",
"iz = lambda x: (m(x) * r**2)/2\n",
"ix = lambda x: (1/12)*m(x)*(3*r**2 + alh(x) **2)\n",
"iy = lambda x: (1/12)*m(x)*(3*r**2 + alh(x) **2)"
]
},
{
"cell_type": "code",
"execution_count": 11,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"2.495\n",
"1.2475007770347213\n",
"1.2475007770347213\n"
]
}
],
"source": [
"print(iz(1))\n",
"print(ix(1))\n",
"print(iy(1))"
]
},
{
"cell_type": "code",
"execution_count": 14,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"2.44\n",
"1.2200007292056354\n",
"1.2200007292056354\n",
"4.88\n",
"0.001339077522946709\n"
]
}
],
"source": [
"print(iz(2))\n",
"print(ix(2))\n",
"print(iy(2))\n",
"print(m(2))\n",
"print(alh(2))"
]
},
{
"cell_type": "code",
"execution_count": 15,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"2.3850000000000002\n",
"1.1925006833792922\n",
"1.1925006833792922\n",
"4.7700000000000005\n",
"0.0013111800745519862\n"
]
}
],
"source": [
"print(iz(3))\n",
"print(ix(3))\n",
"print(iy(3))\n",
"print(m(3))\n",
"print(alh(3))"
]
},
{
"cell_type": "code",
"execution_count": null,
Expand All @@ -360,7 +466,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.10.7"
"version": "3.10.6"
},
"orig_nbformat": 4,
"vscode": {
Expand Down
9 changes: 8 additions & 1 deletion tests/test_liquidmotor.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,14 @@ def test_com():
test(tcom, acom)

def test_inertia():
i = t.inertiaTensor()
alv = lambda x: (initial_liquid_mass + (liquid_mass_flow_rate_in - liquid_mass_flow_rate_out) * x) / lox.density
alh = lambda x: alv(x) / (np.pi)
m = lambda x: (initial_liquid_mass + (liquid_mass_flow_rate_in - liquid_mass_flow_rate_out) * x) + \
(initial_gas_mass + (gas_mass_flow_rate_in - gas_mass_flow_rate_out) * x)
r = 1
iz = lambda x: (m(x) * r**2)/2
ix = lambda x: (1/12)*m(x)*(3*r**2 + alh(x) **2)
iy = lambda x: (1/12)*m(x)*(3*r**2 + alh(x) **2)
test(i, 0)


Expand Down

0 comments on commit 3dccd0e

Please sign in to comment.