Exemple #1
0
    def test_add_unit(self):
        try:
            add_unit('ft', '20*m')
        except KeyError as err:
            self.assertEqual(
                err.args[0], "Unit 'ft' already defined with different factor or powers.")
        else:
            self.fail("Expecting Key Error")

        try:
            add_offset_unit('degR', 'degK', 20, 10)
        except KeyError as err:
            self.assertEqual(
                err.args[0], "Unit 'degR' already defined with different factor or powers.")
        else:
            self.fail("Expecting Key Error")
Exemple #2
0
    def test_add_unit(self):
        try:
            add_unit('ft', '20*m')
        except KeyError as err:
            self.assertEqual(
                str(err), "'Unit ft already defined with different factor or powers'")
        else:
            self.fail("Expecting Key Error")

        try:
            add_offset_unit('degR', 'degK', 20, 10)
        except KeyError as err:
            self.assertEqual(
                str(err), "'Unit degR already defined with different factor or powers'")
        else:
            self.fail("Expecting Key Error")
Exemple #3
0
    def test_add_unit(self):
        try:
            add_unit('ft', '20*m')
        except KeyError as err:
            self.assertEqual(
                str(err),
                "'Unit ft already defined with different factor or powers'")
        else:
            self.fail("Expecting Key Error")

        try:
            add_offset_unit('degR', 'degK', 20, 10)
        except KeyError as err:
            self.assertEqual(
                str(err),
                "'Unit degR already defined with different factor or powers'")
        else:
            self.fail("Expecting Key Error")
Exemple #4
0
from __future__ import print_function, division, absolute_import

import numpy as np
import openmdao.api as om
import openmdao.utils.units as units

# Add canonical units to OpenMDAO
MU_earth = 3.986592936294783e14
R_earth = 6378137.0

period = 2 * np.pi * np.sqrt(R_earth**3 / MU_earth)

# Add canonical time and distance units for these EOM
units.add_unit('TU', '{0}*s'.format(period))
units.add_unit('DU', '{0}*m'.format(R_earth))


class FiniteBurnODE(om.ExplicitComponent):
    def initialize(self):
        self.options.declare('num_nodes', types=int)

    def setup(self):
        nn = self.options['num_nodes']

        # Inputs
        self.add_input('r',
                       val=np.ones(nn),
                       desc='radius from center of attraction',
                       units='DU')

        self.add_input('theta',