Skip to content

Commit

Permalink
tests for ullage tank: pretty far off
Browse files Browse the repository at this point in the history
  • Loading branch information
curtisjhu committed Nov 9, 2022
1 parent fbe5d01 commit 93ff36c
Show file tree
Hide file tree
Showing 7 changed files with 1,009 additions and 53 deletions.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ test:
testfile:
python -m pytest tests/$(file) -vv

tests:
tests:
test

coverage:
Expand Down
34 changes: 8 additions & 26 deletions rocketpy/Function.py
Original file line number Diff line number Diff line change
Expand Up @@ -1936,20 +1936,6 @@ def __rsub__(self, other):
elif callable(other):
return Function(lambda x: (other(x) - self.getValue(x)))

def __eq__(self, other):
""" Checks if two functions are suffiently close enough.
Parameters
----------
other : Function
Returns
-------
result : Boolean
True if the two function's sources are within a tolerance.
"""
return np.allclose(self.source, other.source)

def integral(self, a, b, numerical=False):
"""Evaluate a definite integral of a 1-D Function in the interval
from a to b.
Expand Down Expand Up @@ -2197,27 +2183,23 @@ def functionOfAFunction(self, func, lower=None, upper=None, datapoints=100):
# Checks to make lower bound is given
# If not it will start at the higher of the two lower bounds
if lower is None:
lower_limit_found = False
if isinstance(self.source, np.ndarray):
lower = self.source[0, 0]
lower_limit_found = True
if isinstance(func.source, np.ndarray):
lower = max(lower, func.source[0, 0])
if not lower_limit_found:
raise ValueError("Lower limit must be given if source is a function.")
lower = func.source[0, 0] if lower is None else max(lower, func.source[0, 0])
if lower is None:
raise ValueError("If Functions.source is a <class 'function'>, must provide bounds")

# Checks to make upper bound is given
# If not it will end at the lower of the two upper bounds
if upper is None:
upper_limit_found = False
if isinstance(self.source, np.ndarray):
upper = self.source[-1, 0]
upper_limit_found = True
if isinstance(func.source, np.ndarray):
upper = min(upper, func.source[-1, 0])
if not upper_limit_found:
raise ValueError("Upper limit must be given if source is a function.")
upper = func.source[-1, 0] if upper is None else min(upper, func.source[-1, 0])
if upper is None:
raise ValueError("If Functions.source is a <class 'function'>, must provide bounds")

# Create a new Function object
xData = np.linspace(lower, upper, datapoints)
yData = np.zeros(datapoints)
Expand Down
2 changes: 1 addition & 1 deletion rocketpy/motors/LiquidMotor.py
Original file line number Diff line number Diff line change
Expand Up @@ -339,7 +339,7 @@ def netMassFlowRate(self):
mfr.setOutputs("Mass Flow Rate")
return mfr

def evaluateUllageHeight(self):
def liquidHeight(self):
return self.ullageHeight

def liquidMass(self):
Expand Down
543 changes: 543 additions & 0 deletions test_export_data_1.csv

Large diffs are not rendered by default.

27 changes: 27 additions & 0 deletions test_export_data_1.kml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
<?xml version="1.0" encoding="UTF-8"?>
<kml xmlns="http://www.opengis.net/kml/2.2" xmlns:gx="http://www.google.com/kml/ext/2.2">
<Document id="1">
<Style id="4">
<LineStyle id="5">
<color>641400F0</color>
<colorMode>normal</colorMode>
</LineStyle>
<PolyStyle id="6">
<color>641400F0</color>
<colorMode>normal</colorMode>
<fill>1</fill>
<outline>1</outline>
</PolyStyle>
</Style>
<open>1</open>
<Placemark id="3">
<name>Rocket Trajectory - Powered by RocketPy</name>
<styleUrl>#4</styleUrl>
<LineString id="2">
<extrude>1</extrude>
<altitudeMode>absolute</altitudeMode>
<coordinates>-106.974998,32.990254,1400.0 -106.974998,32.990254,1400.003323969836 -106.974998,32.990254,1400.0099775060019 -106.974998,32.990254,1400.0299549381893 -106.974998,32.990254,1400.063295590361 -106.974998,32.990254,1400.1100445549 -106.974998,32.99025504228052,1401.32487432759 -106.974998,32.99025677895837,1403.5324181110088 -106.974998,32.9902569012104,1403.6870997814408 -106.974998,32.99025702664944,1403.8451162925091 -106.974998,32.99025728390973,1404.1678300308504 -106.974998,32.9902575539508,1404.5039273167708 -106.974998,32.99025783680539,1404.8534524688282 -106.974998,32.99025905127987,1406.331628415077 -106.974998,32.990260459664704,1408.0137437227243 -106.974998,32.990262063942744,1409.9024060480233 -106.974998,32.99026386625126,1412.0002906466893 -106.974998,32.99026796864583,1416.713675062725 -106.974998,32.990272857621854,1422.25696925152 -106.974998,32.990272914954616,1422.3216012597238 -106.974998,32.99027297238274,1422.3863329300636 -106.974998,32.99027302990629,1422.4511642898506 -106.974998,32.99027303740013,1422.4596100082617 -106.974998,32.99027304489558,1422.4680574179283 -106.974998,32.990273059889724,1422.4849556198928 -106.974998,32.99027306018967,1422.485293654291 -106.974998,32.99027306048963,1422.4856316913952 -106.974998,32.99027306078958,1422.4859697312056 -106.974998,32.99027306108954,1422.4863077737223 -106.974998,32.99027306138951,1422.4866458189451 -106.974998,32.99027306198943,1422.4873219148035 -106.974998,32.99027306258936,1422.4879980182375 -106.974998,32.990273063189285,1422.4886741227476 -106.974998,32.99027306918864,1422.495434939669 -106.974998,32.99027307518796,1422.5021955392758 -106.974998,32.990273135180345,1422.5697906697958 -106.974998,32.99027319517092,1422.637364069525 -106.974998,32.990273255159686,1422.7049157390832 -106.974998,32.99027385494833,1423.3792374623088 -106.974998,32.99027445455714,1424.0513868475166 -106.974998,32.99027505398653,1424.7213645091615 -106.974998,32.990275837688266,1425.5943269091672 -106.974998,32.99027662108587,1426.4635769670501 -106.974998,32.990277404181356,1427.3291160310346 -106.974998,32.99027919535763,1429.2961465591088 -106.974998,32.990280985000126,1431.24376059419 -106.974998,32.99028277315105,1433.1719737430951 -106.974998,32.990286176196506,1436.792198700256 -106.974998,32.99028957439557,1440.34215537833 -106.974998,32.99029280709657,1443.6582731128044 -106.974998,32.99029603616393,1446.9108125890693 -106.974998,32.99029926197179,1450.0998569853425 -106.974998,32.99030248487493,1453.2254875883225 -106.974998,32.99030570519581,1456.2877839991597 -106.974998,32.990308923215224,1459.286824311818 -106.974998,32.99031213916681,1462.22268524893 -106.974998,32.99031545595306,1465.18623227341 -106.974998,32.990318770888976,1468.0826583229277 -106.974998,32.99032208406043,1470.9120434173853 -106.974998,32.990325395507476,1473.6744663721558 -106.974998,32.99032870523238,1476.370004775374 -106.974998,32.99033288704417,1479.6822333309015 -106.974998,32.990337065921224,1482.887830144513 -106.974998,32.99034124167791,1485.9869417021434 -106.974998,32.99034541409407,1488.9797102606287 -106.974998,32.99034958293317,1491.8662736610402 -106.974998,32.99035462321717,1495.2179272843532 -106.974998,32.990359657502914,1498.4144390728693 -106.974998,32.99036468542218,1501.4560255215229 -106.974998,32.99036970665624,1504.3428925856113 -106.974998,32.99037472093242,1507.0752357689398 -106.974998,32.99037972802324,1509.6532402124856 -106.974998,32.99038711336078,1513.180533566359 -106.974998,32.990394482205595,1516.371727205011 -106.974998,32.990401834306056,1519.227297616303 -106.974998,32.99040916954673,1521.7476748053964 -106.974998,32.990416487936585,1523.9332426321291 -106.974998,32.99042508373687,1526.0779307734863 -106.974998,32.990432045667426,1527.4783785379834 -106.974998,32.99043899312898,1528.573684825185 -106.974998,32.99044592666498,1529.3640115007684 -106.974998,32.99045093605791,1529.745821714934 -106.974998,32.990451937099955,1529.8030277197122 -106.974998,32.990452937860084,1529.8538492233067 -106.974998,32.990453938335435,1529.8982866293502 -106.974998,32.99045493852243,1529.9363403618595 -106.974998,32.99045693800949,1529.9932987623279 -106.974998,32.99045893626813,1530.024728716839 -106.974998,32.99046093322066,1530.0306355342711 -106.974998,32.990462928758326,1530.0110259233227 -106.974998,32.9904652935723,1529.9546992941214 -106.974998,32.99046765587844,1529.8625070081996 -106.974998,32.99047001525534,1529.7344729709394 -106.974998,32.990472371178186,1529.570627466813 -106.974998,32.99047472301558,1529.3710079691846 -106.974998,32.99047833223521,1528.994069864006 -106.974998,32.990481926783154,1528.5327449729828 -106.974998,32.990485502868935,1527.987299103715 -106.974998,32.990489056196544,1527.3580623932808 -106.974998,32.99049180343014,1526.8105067188549 -106.974998,32.99049453172023,1526.212642275144 -106.974998,32.990497238727215,1525.5647219741534 -106.974998,32.990499922152466,1524.8670311295657 -106.974998,32.99050257981663,1524.1198888102542 -106.974998,32.990505209750026,1523.3236483920584 -106.974998,32.9905073585763,1522.6296622134448 -106.974998,32.9905094866428,1521.9027183071746 -106.974998,32.990511593470664,1521.1430633291718 -106.974998,32.99051367886271,1520.3509541969624 -106.974998,32.99051574294574,1519.5266546664805 -106.974998,32.990518303655136,1518.4471709086133 -106.974998,32.99052083346268,1517.317937215056 -106.974998,32.99052333527939,1516.139441128595 -106.974998,32.990525813092106,1514.9121155445448 -106.974998,32.990528271902235,1513.6363128748278 -106.974998,32.99053071760602,1512.3122769286301 -106.974998,32.99053347709395,1510.7562909250503 -106.974998,32.99053623842686,1509.1386040601135 -106.974998,32.99053901174437,1507.4588240730448 -106.974998,32.9905418062682,1505.7162490492076 -106.974998,32.990544629281565,1503.909882421334 -106.974998,32.99054748504646,1502.038485313552 -106.974998,32.990549736582935,1500.5320823486002 -106.974998,32.990552006334056,1498.9845707300685 -106.974998,32.99055429038425,1497.3953408726234 -106.974998,32.990556134467965,1496.0861000717816 -106.974998,32.99055798014192,1494.749353510361 -106.974998,32.99055982288792,1493.3850180583065 -106.974998,32.990561657727746,1491.9931195896802 -106.974998,32.99056347943172,1490.5738023291538 -106.974998,32.990565282750254,1489.1273310721058 -106.974998,32.9905670626429,1487.6540850257652 -106.974998,32.990568814481584,1486.154543273604 -106.974998,32.99057053420747,1484.629263199355 -106.974998,32.99057221842668,1483.0788539793164 -106.974998,32.99057386443786,1481.5039475202548 -106.974998,32.99057547019484,1479.9051692077944 -106.974998,32.990577034216365,1478.2831105455718 -106.974998,32.99057855546102,1476.6383051753799 -106.974998,32.990580033187975,1474.9712090261953 -106.974998,32.990581466823436,1473.2821847056139 -106.974998,32.990582855850434,1471.5714898745962 -106.974998,32.99058419973595,1469.8392692234127 -106.974998,32.99058549790474,1468.0855497166779 -106.974998,32.99058674976454,1466.3102389448406 -106.974998,32.99058795478292,1464.513126682546 -106.974998,32.99058911261191,1462.693890007555 -106.974998,32.99059022325264,1460.8521024802944 -106.974998,32.99059128724811,1458.9872480890401 -106.974998,32.990592417050856,1456.8860917396978 -106.974998,32.990593493970955,1454.7548284096838 -106.974998,32.99059452289392,1452.5925744185995 -106.974998,32.99059551062236,1450.3984933458987 -106.974998,32.990596298576264,1448.5687934726245 -106.974998,32.99059707035812,1446.7167433847062 -106.974998,32.99059783248787,1444.8421400489353 -106.974998,32.99059859200949,1442.9449057376055 -106.974998,32.990599356257974,1441.0250988567507 -106.974998,32.99060013259548,1439.0829158409801 -106.974998,32.99060092814235,1437.118682481951 -106.974998,32.990601749532246,1435.1328347202575 -106.974998,32.99060260271722,1433.125890596916 -106.974998,32.99060349283992,1431.098416075349 -106.974998,32.99060442417843,1429.0509878598903 -106.974998,32.99060540015774,1426.9841563738933 -106.974998,32.990606423412615,1424.8984115974404 -106.974998,32.99060749587601,1422.7941545265196 -106.974998,32.99060861886955,1420.6716751246784 -106.974998,32.99060979317359,1418.531137314623 -106.974998,32.990611019059756,1416.3725712323442 -106.974998,32.99061229627739,1414.1958727491553 -106.974998,32.99061362399303,1412.00081014712 -106.974998,32.990615000689914,1409.7870377422862 -106.974998,32.99061642404134,1407.5541161601152 -106.974998,32.99061789077769,1405.3015388216058 -106.974998,32.99061939657087,1403.0287638764291 -106.974998,32.9906209359607,1400.7352502436731 -106.974998,32.990621432493036,1400.0000002448091</coordinates>
</LineString>
</Placemark>
</Document>
</kml>
Loading

0 comments on commit 93ff36c

Please sign in to comment.