Skip to content

Commit e0c9f10

Browse files
committed
initial commit
0 parents  commit e0c9f10

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

54 files changed

+6513
-0
lines changed

.gitignore

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
Manifest.toml
2+
examples/.ipynb_checkpoints/**
3+
examples/dev_tests/.ipynb_checkpoints/**
4+
examples/local/**
5+
data/**
6+
local_tests
7+
.vscode/**
8+
.DS_Store
9+
.DS_Store
10+
docs/build/**
11+
examples/jdp.mplstyle

Project.toml

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
name = "HarmonicBalance"
2+
uuid = "e13b9ff6-59c3-11ec-14b1-f3d2cc6c135e"
3+
authors = ["Jan Kosata <kosataj@phys.ethz.ch>", "Javier del Pino <jdelpino@phys.ethz.ch>"]
4+
version = "0.3.0"
5+
6+
[deps]
7+
BijectiveHilbert = "91e7fc40-53cd-4118-bd19-d7fcd1de2a54"
8+
Conda = "8f4d0f93-b110-5947-807f-2305c1781a2d"
9+
DSP = "717857b8-e6f2-59f4-9121-6e50c889abd2"
10+
DataFrames = "a93c6f00-e57d-5684-b7b6-d8193f3e46c0"
11+
DataStructures = "864edb3b-99cc-5e75-8d2d-829cb0a9cfe8"
12+
DifferentialEquations = "0c46a032-eb83-5123-abaf-570d42b7fbaa"
13+
Distances = "b4f34e82-e78d-54a5-968a-f98e89d6e8f7"
14+
DocStringExtensions = "ffbed154-4ef7-542d-bbb7-c09d3a79fcae"
15+
Documenter = "e30172f5-a6a5-5a46-863b-614d45cd2de4"
16+
FFTW = "7a1cc6ca-52ef-59f5-83cd-3a7055c09341"
17+
Gtk = "4c0ca9eb-093a-5379-98c5-f87ac0bbbf44"
18+
HomotopyContinuation = "f213a82b-91d6-5c5d-acf7-10f1c761b327"
19+
JLD2 = "033835bb-8acc-5ee8-8aae-3f567f8a3819"
20+
LaTeXStrings = "b964fa9f-0449-5b57-a5c2-d3ea65f4040f"
21+
Latexify = "23fbe1c1-3f47-55db-b15f-69d7ec21a316"
22+
LinearAlgebra = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e"
23+
Peaks = "18e31ff7-3703-566c-8e60-38913d67486b"
24+
Polyester = "f517fe37-dbe3-4b94-8317-1923a5111588"
25+
Printf = "de0858da-6303-5e67-8744-51eddeeeb8d7"
26+
PyCall = "438e738f-606a-5dbb-bf0a-cddfbfd45ab0"
27+
PyPlot = "d330b81b-6aea-500a-939a-2ce795aea3ee"
28+
REPL = "3fa0cd96-eef1-5676-8a61-b3b8758bbffb"
29+
RecursiveArrayTools = "731186ca-8d62-57ce-b412-fbd966d074cd"
30+
SymbolicUtils = "d1185830-fcd6-423d-90d6-eec64667417b"
31+
Symbolics = "0c5d862f-8b57-4792-8d23-62f2024744c7"
32+
33+
[compat]
34+
Polyester = ">= 0.4.2"
35+
Symbolics = ">=3.4.3"
36+
julia = ">=1.7.0"

README.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
# HarmonicBalance.jl
2+
3+
## Installation
4+
5+
## Example
6+
7+
## Authors

docs/make.jl

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
using Pkg
2+
current_path = @__DIR__
3+
Pkg.activate(current_path * "/../.");
4+
5+
using Documenter, HarmonicBalance
6+
7+
makedocs(
8+
sitename="HarmonicBalance.jl",
9+
#format = Documenter.HTML(assets = [])
10+
pages = [
11+
"Examples" => Any[
12+
"examples/ex1.md"
13+
"examples/ex2.md"
14+
],
15+
"Manual" => Any[
16+
"manual/entering_eom.md"
17+
"manual/extracting_harmonics.md"
18+
"manual/solving_harmonics.md"
19+
"manual/plotting.md"
20+
"manual/time_dependent.md"
21+
"manual/linear_response.md"
22+
]
23+
]
24+
)

docs/src/assets/logo.png

143 KB
Loading

docs/src/examples/ex1.md

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
# Example 1
2+
3+
some text
4+
5+
markdown:
6+
```julia
7+
using HarmonicBalance.jl
8+
```
9+
10+
First, we need to define the symbolic variables to be used. The syntax here is inherited from Symbolics.jl
11+
```julia
12+
@variables
13+
```
14+
15+
These are used to define an equation of motion
16+
```julia
17+
dEOM = HarmonicBalance.DifferentialEquation
18+
```
19+
20+
This object now holds the equations and identifies its variables.
21+
22+
Now we must specify which harmonics will be used to expand which variable, let's start with using the single
23+
```julia
24+
HarmonicBalance.add_harmonic!(dEOM, x, ω)
25+
```
26+
27+
The problem is now fully specified - we may convert the differential equation into a
28+
```julia
29+
averagedEOM
30+
```
31+
32+
We may now inspect the generated equations. The conversion has generated new variables describing each harmonic.
33+
```julia
34+
averagedEOM.equations
35+
```
36+
37+
This object is the central point of the HarmonicBalance.jl framework. It may be fed into an algebraic or a time-dependent solver.
38+
39+
```julia
40+
averagedEOM
41+
```
42+
43+
We are now ready to use the homotopy continuation method to obtain all the solutions of our algebraic equations. This is typically done across a set of parameters.
44+
45+
```julia
46+
ParameterRange
47+
get_steady_states
48+
```
49+
50+
51+
So far, the equation have been relatively uncomplicated. However, due to the presence of the cubic nonlinearity, the ansatz ... $``$ does not fully describe the behaviour of our system. Frequency conversion - to first order, from ω to 3ω - will occur. To see the effect of this, we may expand the motion in both harmonics.
52+
```julia
53+
HarmonicBalance.add_harmonic!(dEOM, x, [ω, 3ω])
54+
```
55+
56+
The generated equations are not perturbative - all harmonics are treated on the same footing. The newly generated variables are (pretty print of VDP types). Proceeding to a solution diagram as before, we may now plot the two harmonics separately.
57+
58+
59+
We see that, although the third harmonic is clearly present, our solution landscape did not change much. In later examples, we will see this is not always the case.
60+
61+
62+
63+
To sort: hyperlinks

docs/src/examples/ex2.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
# Example 2

docs/src/index.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
# Home
2+
3+
This is the main page
4+
5+
## Installation

docs/src/manual/entering_eom.md

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
# Entering equations of motion
2+
3+
The struct `DifferentialEquation` is the primary input method; it holds an ODE or a coupled system of ODEs. The dependent variables are specified during input, any other symbols
4+
are identified as parameters. Information on which variable is to be expanded in which harmonic is specified using `add_harmonic!`.
5+
6+
`DifferentialEquation.equations` stores a dictionary assigning variables to equations. This is because the harmonics belonging to a variable are later used to Fourier-transform its corresponding ODE.
7+
8+
```@docs
9+
DifferentialEquation
10+
add_harmonic!
11+
get_variables(::DifferentialEquation)
12+
get_independent_variables(::DifferentialEquation)
13+
```
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
# Extracting harmonic equations
2+
3+
Once a `DifferentialEquation` is defined and its harmonics specified, one can extract the harmonic equations using `get_harmonic_equations`, which itself is composed of the subroutines `harmonic_ansatz`, `slow_flow`, `fourier_transform!` and `drop_powers`.
4+
5+
6+
```@docs
7+
get_harmonic_equations
8+
HarmonicBalance.harmonic_ansatz
9+
HarmonicBalance.slow_flow
10+
HarmonicBalance.fourier_transform
11+
HarmonicBalance.drop_powers
12+
```
13+
14+
## HarmonicVariable and HarmonicEquation types
15+
16+
The equations governing the harmonics are stored using the two following structs. When going from the original to the harmonic equations, the harmonic ansatz $x_i(t) = \sum_{j=1}^M u_i^{(j)} (T) \cos(\omega_j^{(i)} t)+ v_i^{(j)} (T) \sin(\omega_j^{(i)} t)$ is used. Internally, each pair $(u_i^{(j)}, v_i^{(j)})$ is stored as a `HarmonicVariable`. This includes the identification of $\omega_j^{(i)}$ and $x_i(t)$, which is needed to later reconstruct the solutions in the non-rotating frame.
17+
18+
```@docs
19+
HarmonicVariable
20+
```
21+
22+
When the full set of equations of motion is expanded using the harmonic ansatz, the result is stored as a `HarmonicEquation`. For an initial equation of motion consisting of $M$ variables, each expanded in $N$ harmonics, the resulting `HarmonicEquation` holds $2NM$ equations of $2NM$ variables. Each symbol not corresponding to a variable is identified as a parameter.
23+
24+
A `HarmonicEquation` can be either parsed into a steady-state `Problem` or solved using a dynamical ODE solver.
25+
26+
```@docs
27+
HarmonicEquation
28+
```

0 commit comments

Comments
 (0)