Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Just a question, not an issue #528

@Peter230655

Description

@Peter230655

Trying to get started with this code generation thing, I simply copied an example given in the codegen section of the introduction, see below.

  1. The result given in the documentation is [2., -7.], I get [2., -1.3333333], maybe no big deal.
  2. As I see it, the system is a simple mass oscillator with parameters c0, k0, m0. and generalized coordinates/speeds x0, v0
    In the line rhs(array([1.0, 2.0]), 0.0, array([1.0, 2.0, 3.0])) I do not understand why the first argument is an array[1.0, 2.0]. does this not correspond to x0(t), like the second entry corresponds to v0(t)?

Thanks

from numpy import array
from pydy.models import multi_mass_spring_damper
from pydy.codegen.ode_function_generators import generate_ode_function

sys = multi_mass_spring_damper()
sym_rhs = sys.eom_method.rhs()

q = sys.coordinates
u = sys.speeds
p = sys.constants_symbols
print(q, u, p)
print(sym_rhs)

rhs = generate_ode_function(sym_rhs, q, u, p, generator='cython')

rhs(array([1.0, 2.0]), 0.0, array([1.0, 2.0, 3.0]))

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions