# convert the values to my coordinates and speeds
mooreInput = bicycle.basu_to_moore_input(basuInput, benchmarkPar['rR'],
        benchmarkPar['lam'])

# store them in a state array
x = np.array([mooreInput[x] for x in whip.stateNames])

# calculate the derivatives of the state using my model and compare it to
# BasuMandal2007
xd = whip.f(x, 0.)
y = whip.outputs(x)

# convert the outputs from my model to the Basu-Mandal coordinates
mooreOutput = {k : v for k, v in zip(whip.outputNames, y)}
mooreOutputBasu = bicycle.moore_to_basu(mooreOutput, benchmarkPar['rR'], benchmarkPar['lam'])
basuOutput = bicycle.basu_table_one_output()

# make an rst list table
def rst_math(s):
    """Returns the variable name as reStructuredText math notation."""

    mapping = {'x': r'x',
               'y': r'y',
               'z': r'z',
               'theta': r'\theta',
               'psi': r'\psi',
               'phi': r'\phi',
               'psif': r'\psi_f',
               'betar': r'\beta_r',
               'betaf': r'\beta_f'}
Example #2
0
print("Generating output dictionary.")
# convert the outputs from my model to the Basu-Mandal coordinates
# TODO : raise an issue about not knowing which order the x vector is in with
# reference to M * x' = F
states = kane._q + kane._u
state_names = [str(state)[:-3] + 'p' for state in states]
moore_output = {k : v for k, v in zip(state_names, list(xd))}
u1 = -rr * u6 * sym.cos(q3)
u1p = u1.diff(t)
u2 = -rr * u6 * sym.sin(q3)
u2p = u2.diff(t)
moore_output['u1p'] = u1p.subs({u6d: moore_output['u6p']}).subs(kane.kindiffdict()).subs(substitutions)
moore_output['u2p'] = u2p.subs({u6d: moore_output['u6p']}).subs(kane.kindiffdict()).subs(substitutions)
moore_output.update(moore_input)

moore_output_basu = bicycle.moore_to_basu(moore_output, bp['rR'], bp['lam'])
basu_output = bicycle.basu_table_one_output()

print("Assertions.")
from numpy import testing

for k, bv in basu_output.items():
    mv = float(moore_output_basu[k])
    try:
        testing.assert_allclose(bv, mv)
    except AssertionError:
        print('Failed: {} is supposed to be {} but is {}'.format(k, bv, mv))

# Try with lambdify

from benchmark_functions import numeric_right_hand_side
Example #3
0
states = kane._q + kane._u
state_names = [str(state)[:-3] + 'p' for state in states]
moore_output = {k: v for k, v in zip(state_names, list(xd))}
u1 = -rr * u6 * sym.cos(q3)
u1p = u1.diff(t)
u2 = -rr * u6 * sym.sin(q3)
u2p = u2.diff(t)
moore_output['u1p'] = u1p.subs({
    u6d: moore_output['u6p']
}).subs(kane.kindiffdict()).subs(substitutions)
moore_output['u2p'] = u2p.subs({
    u6d: moore_output['u6p']
}).subs(kane.kindiffdict()).subs(substitutions)
moore_output.update(moore_input)

moore_output_basu = bicycle.moore_to_basu(moore_output, bp['rR'], bp['lam'])
basu_output = bicycle.basu_table_one_output()

print("Assertions.")
from numpy import testing

for k, bv in basu_output.items():
    mv = float(moore_output_basu[k])
    try:
        testing.assert_allclose(bv, mv)
    except AssertionError:
        print('Failed: {} is supposed to be {} but is {}'.format(k, bv, mv))

# Try with lambdify

from pydy_code_gen.code import generate_ode_function
Example #4
0
# convert the values to my coordinates and speeds
mooreInput = bicycle.basu_to_moore_input(basuInput, benchmarkPar['rR'],
                                         benchmarkPar['lam'])

# store them in a state array
x = np.array([mooreInput[x] for x in whip.stateNames])

# calculate the derivatives of the state using my model and compare it to
# BasuMandal2007
xd = whip.f(x, 0.)
y = whip.outputs(x)

# convert the outputs from my model to the Basu-Mandal coordinates
mooreOutput = {k: v for k, v in zip(whip.outputNames, y)}
mooreOutputBasu = bicycle.moore_to_basu(mooreOutput, benchmarkPar['rR'],
                                        benchmarkPar['lam'])
basuOutput = bicycle.basu_table_one_output()


# make an rst list table
def rst_math(s):
    """Returns the variable name as reStructuredText math notation."""

    mapping = {
        'x': r'x',
        'y': r'y',
        'z': r'z',
        'theta': r'\theta',
        'psi': r'\psi',
        'phi': r'\phi',
        'psif': r'\psi_f',