srenevey / ode-solvers

Numerical methods to solve ordinary differential equations in Rust.
BSD 3-Clause "New" or "Revised" License
64 stars 26 forks source link

it seems not possible to use mixed-type-structs as "State" #10

Open exo-cortex opened 2 years ago

exo-cortex commented 2 years ago

experimenting around with this package I realized that it does not seem possible to use a custom struct (in my case with one complex type and one normal f64 type).

I wanted to implement a lang-kobayashi laser equation (two coupled differential equations, one "E" for the electric field, which is complex, and one "n" representing the number of excited states (or fraction thereof).

Is this package designed to only be used with vectors? or is it possible to have combinations of complex and real states? (these mixed states are often needed in various laser system equations.

srenevey commented 2 years ago

Since a "normal" type can be seen as a complex number with no imaginary part, you might be able to define the type as type State = Vector2<Complex>. I'm not familiar with solving ODEs with complex numbers so I'm not sure if this would work though.