Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

HarmonicBalance Extentions #154

Merged
merged 9 commits into from
Feb 26, 2024
Merged

HarmonicBalance Extentions #154

merged 9 commits into from
Feb 26, 2024

Conversation

oameye
Copy link
Member

@oameye oameye commented Feb 19, 2024

Resolves #98 and #100

@oameye oameye marked this pull request as draft February 19, 2024 19:19
@oameye oameye added enhancement New feature or request formatting Simple style and formatting issue. Does not change functionality. labels Feb 20, 2024
@oameye oameye linked an issue Feb 20, 2024 that may be closed by this pull request
@oameye oameye changed the title Make TimeEvolution module an Extention HarmonicBalance Extentions Feb 20, 2024
@oameye oameye force-pushed the TimeEvolutionExt branch 2 times, most recently from 94a1502 to f9e7d39 Compare February 20, 2024 21:07
@oameye oameye marked this pull request as ready for review February 20, 2024 21:08
@oameye
Copy link
Member Author

oameye commented Feb 21, 2024

I finally got to adding Extensions to HarmonicBalance in this PR. The new features include:

  • All the time evolution feature are now only available when also OrdinaryDiffEq is loaded. This makes loading/compile time less convoluted and reduces our namespace in a normal HB session. I would say that in the future we want something similar with Plots. Allowing the user to choose their plotting package and not have clashing namespaces with for example Makie.plot and Plots.plot.
  • I added a ModelingToolkit extension which get loaded when ModelingToolkit is loaded in the same session. It allows to translate the HarmonicEquation struct to an ODEProblem. The ModelingToolkit framework does this very efficiently by: also compiling Jacobian automatically, freedom to choose in-place or out-of-place, making it statically compiling and adding extra structure for the OrdinaryDiffEq solver to use. The result in a dramatic increase in performance when solver the ODE (from 14ms to 500μs).
  • Lastly, I added a SteadyStateDiffEq extention. For the parameter estimation project I had to rewrite the HarmonicBalance steady state sweep solver. It was highly inefficient ( no use of Jacobian in the RK solver, not static, to many allocations) and it did an interpolation of the parameters sweep where it changed the parameter in every time step. The latter, at first thought, seems a good idea, but it introduces oscillations ( as Soumya was seeing) and you had to evolve for very long which introduces inefficiency and energy loss (timestep integration loss). Instead, we now use a root solver (newton-raphson) following the branch until the branch is unstable (bifurcation) and we use a steady solver to find the next branch. This is similar to what follow branch does but without using HomotopyContinuation. This made it Automatic differentiable needed for optimization algorithms.

Feel free to check it out and review it.

@oameye oameye added the performance Regarding performance of the package label Feb 22, 2024
support for 1.9
try compatibility with julia 1.8
update test.yml to v4
support for julia < 1.9
add OrdinaryDiffEq still as [deps] such that it can be used in 1.8
@jdelpino jdelpino merged commit 7f74df4 into master Feb 26, 2024
3 checks passed
@jdelpino jdelpino deleted the TimeEvolutionExt branch February 26, 2024 11:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request formatting Simple style and formatting issue. Does not change functionality. performance Regarding performance of the package
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Requires.jl Debloat HarmonicBalance.jl
2 participants