forked from OpenMDAO/Aviary
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #6 from szoppelt/new-mass-branch
New mass branch
- Loading branch information
Showing
3 changed files
with
133 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
import unittest | ||
|
||
import openmdao.api as om | ||
from openmdao.utils.assert_utils import assert_check_partials, assert_near_equal | ||
|
||
from aviary.subsystems.mass.simple_mass.fuselage import FuselageMassAndCOG | ||
|
||
class FuselageMassTestCase(unittest.TestCase): | ||
""" | ||
Fuselage mass test case. | ||
""" | ||
|
||
def setUp(self): | ||
|
||
self.prob = om.Problem() | ||
self.prob.model.add_subsystem( | ||
"fuselage", | ||
FuselageMassAndCOG(), | ||
promotes_inputs=["*"], | ||
promotes_outputs=["*"], | ||
) | ||
|
||
self.prob.model.set_input_defaults( | ||
"fuselage_mass", | ||
val=10, | ||
units="kg") | ||
|
||
self.prob.setup( | ||
check=False, | ||
force_alloc_complex=True) | ||
|
||
def test_case(self): | ||
|
||
self.prob.run_model() | ||
|
||
tol=1e-10 | ||
|
||
assert_near_equal( | ||
self.prob["fuselage_mass"], | ||
100, # filler value for now | ||
tol) | ||
|
||
partial_data = self.prob.check_partials( | ||
out_stream=None, | ||
method="fd") # fd for now since cs is used in the fuselage mass calculation right now | ||
|
||
assert_check_partials( | ||
partial_data, | ||
atol=1e-15, | ||
rtol=1e-15) | ||
|
||
if __name__ == "__main__": | ||
unittest.main() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
import unittest | ||
|
||
import openmdao.api as om | ||
from openmdao.utils.assert_utils import assert_check_partials, assert_near_equal | ||
|
||
from aviary.subsystems.mass.simple_mass.tail import TailMassAndCOG | ||
|
||
class TailMassTestCase(unittest.TestCase): | ||
""" | ||
Tail mass test case. | ||
""" | ||
|
||
def setUp(self): | ||
|
||
self.prob = om.Problem() | ||
self.prob.model.add_subsystem( | ||
"Tail", | ||
TailMassAndCOG(), | ||
promotes_inputs=["*"], | ||
promotes_outputs=["*"], | ||
) | ||
|
||
self.prob.model.set_input_defaults( | ||
"tail_mass", | ||
val=10, | ||
units="kg") | ||
|
||
self.prob.setup( | ||
check=False, | ||
force_alloc_complex=True) | ||
|
||
def test_case(self): | ||
|
||
self.prob.run_model() | ||
|
||
tol = 1e-10 | ||
|
||
assert_near_equal( | ||
self.prob["tail_mass"], | ||
100, # still need to calculate by hand | ||
tol) | ||
|
||
partial_data = self.prob.check_partials( | ||
out_stream=None, | ||
method="fd") # Finite difference because cs is used in tail mass calculation right now | ||
|
||
assert_check_partials( | ||
partial_data, | ||
atol=1e-15, | ||
rtol=1e-15) | ||
|
||
if __name__ == "__main__": | ||
unittest.main() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters