JacquesCarette / Drasil

Generate all the things (focusing on research software)
https://jacquescarette.github.io/Drasil
BSD 2-Clause "Simplified" License
142 stars 26 forks source link

Collect θ2 as the numerical solution - Double Pendulum #3053

Open cd155 opened 2 years ago

cd155 commented 2 years ago

Currently, we only collect the θ1 as the numerical solution in Double pendulum.

https://github.com/JacquesCarette/Drasil/blob/21904c715546944d36e75a4ca91c710d92e98149/code/stable/dblpendulum/src/python/Calculations.py#L22-L24

https://github.com/JacquesCarette/Drasil/blob/21904c715546944d36e75a4ca91c710d92e98149/code/stable/dblpendulum/src/java/DblPendulum/ODEStepHandler.java#L30-L32

https://github.com/JacquesCarette/Drasil/blob/21904c715546944d36e75a4ca91c710d92e98149/code/stable/dblpendulum/src/csharp/Calculations.cs#L31-L33

https://github.com/JacquesCarette/Drasil/blob/21904c715546944d36e75a4ca91c710d92e98149/code/stable/dblpendulum/src/cpp/Populate.cpp#L10-L12

The index 0 is θ1 and the index 1 is θ2. We want to collect the θ2 as well. I think this makes us think about what kind of output we want as the numerical solution. Currently, the output module will create a text file with a list of numbers. If we want to print θ2 in the created text file, we can pass a list of lists of numbers to the output module instead of just a list of numbers. Another idea is that output the θ2 in a separate text file.

It requires writing new instructions of how to generate code. Most code defined in ODELibraries.hs.

smiths commented 1 year ago

Thank you for pointing this out @cd155. What we eventually want to do is teach the generator what to do with a list of dependent variables. In cases like this we have a system of ODEs from the start (not just a system introduced to reduce the order of a single higher order ode). In this case we have two equations and two unknowns, but in general we could have n equations and n unknowns. Drasil is able to work with the input in the form of multiple equations, but it doesn't know that there should be one output per equation in the initial system. This means teaching it more about systems of ODEs.