Skip to content

Commit c528a86

Browse files
committed
docs: complete API list
1 parent d634355 commit c528a86

File tree

4 files changed

+164
-10
lines changed

4 files changed

+164
-10
lines changed

docs/src/API.md

Lines changed: 57 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,73 @@
1+
```@meta
2+
CollapsedDocStrings = true
3+
```
4+
15
# API
26

3-
## Symbolic Utilities
7+
```@contents
8+
Pages = ["API.md"]
9+
Depth = 2:3
10+
```
11+
12+
## Classical harmonic systems
13+
14+
### Classical equations of motion in lab frame
415

516
```@docs
17+
QuestBase.DifferentialEquation
18+
QuestBase.rearrange_standard!(::QuestBase.DifferentialEquation)
19+
QuestBase.rearrange!
20+
QuestBase.is_rearranged_standard
21+
QuestBase.get_equations
22+
QuestBase.get_independent_variables(::QuestBase.DifferentialEquation)
23+
QuestBase.get_variables(::QuestBase.DifferentialEquation)
24+
```
25+
26+
### Harmonics
627

28+
```@docs
29+
QuestBase.HarmonicVariable
30+
QuestBase.add_harmonic!
731
```
832

9-
## Classical harmonic systems
33+
### Effective stroboscopic equations of motion in a rotating frame
34+
35+
```@docs
36+
QuestBase.HarmonicEquation
37+
QuestBase.get_independent_variables(::QuestBase.HarmonicEquation)
38+
QuestBase.get_variables(::QuestBase.HarmonicEquation)
39+
QuestBase.rearrange_standard(::QuestBase.HarmonicEquation)
40+
QuestBase.rearrange_standard!(::QuestBase.HarmonicEquation)
41+
QuestBase.rearrange
42+
QuestBase.is_rearranged
43+
```
44+
45+
## Steady state methods
1046

1147
```@docs
48+
QuestBase.HarmonicBalanceMethod
49+
```
50+
51+
## Symbolic Utilities
1252

53+
QuestBase contains a number of symbolic utilities to help with the symbolic manipulation of the equations of motion. These are function on the top of the Symbolics.jl package and are consired **non-public**.
54+
55+
```@docs
56+
QuestBase.d
1357
```
1458

15-
## Classical harmonic systems
59+
### Exponentials
1660

1761
```@docs
62+
QuestBase.simplify_exp_products
63+
QuestBase.expand_exp_power
64+
```
65+
66+
### Trigonometrics
1867

68+
```@docs
69+
QuestBase.trig_reduce
70+
QuestBase.is_trig
71+
QuestBase.exp_to_trig
72+
QuestBase.trig_to_exp
1973
```

docs/src/index.md

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,21 @@ It is designed ensure compatiabilty between the different available packages.
66
This documentation is made to pool together the docs of the various Quest libraries
77
to paint the overarching picture and document the shared/common functionality.
88

9-
<!-- ## Packages of Quest Ecosystem -->
9+
## Packages of Quest Ecosystem
10+
11+
### [HarmonicBalance.jl](https://github.com/QuantumEngineeredSystems/HarmonicBalance.jl):
12+
13+
A package for applying the harmonic balance method to classical driven nonlinear resonators.
14+
It computes the stroboscopic effective equations of motion of the system at the characteristic response frequencies of the system.
15+
Both [Krylov-Bogoliubov](https://quantumengineeredsystems.github.io/HarmonicBalance.jl/stable/manual/extracting_harmonics#Krylov-Bogoliubov) averaging method to higher orders and the [harmonic balance method](https://quantumengineeredsystems.github.io/HarmonicBalance.jl/stable/manual/extracting_harmonics#Krylov-Bogoliubov) are implemented.
16+
17+
### [HarmonicSteadyState.jl](https://github.com/QuantumEngineeredSystems/HarmonicSteadyState.jl)
18+
19+
A package for computing the classical steady state of the effective stroboscopic systems driven nonlinear resonators. Given one has the autonomous equations of motion of the system in the rotating frame of the characteristic response frequencies, it collect steady states methods to find and describe the stationary responses of the system. It supports the following methods:
20+
21+
- fixed point steady states with Homotopy Continuation
22+
- Finding Limit-cycle with Homotopy Continuation
23+
- Stability analysis
24+
- Linear response of the steady state in the (non-)rotating frame
25+
- Parameter sweeps
26+
- Plotting utilities

src/HarmonicEquation.jl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -149,6 +149,7 @@ function rearrange!(eom::HarmonicEquation, new_rhs::Vector{Num})
149149
return nothing
150150
end
151151

152+
"Rearrange an equation system such that the field equations is equal to the vector specified in new_lhs"
152153
function rearrange(eom::HarmonicEquation, new_rhs::Vector{Num})
153154
new_eom = deepcopy(eom)
154155
rearrange!(new_eom, new_rhs)

src/Symbolics/fourier.jl

Lines changed: 88 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,26 @@
1+
"""
2+
trig_reduce(x)
3+
4+
Simplify trigonometric expressions by converting between exponential and trigonometric forms.
5+
This function performs the following steps:
6+
1. Combines fractions with common denominators
7+
2. Expands all brackets
8+
3. Converts trigonometric functions to exponentials
9+
4. Expands products of exponentials
10+
5. Simplifies exponential products
11+
6. Converts back to trigonometric form
12+
7. Simplifies complex expressions
13+
14+
Returns the simplified expression as a `Num` type.
15+
"""
116

2-
"Expand all sin/cos powers in `x`."
17+
"""
18+
is_trig(f::Num)
19+
20+
Check if the given expression `f` is a trigonometric function (sine or cosine).
21+
22+
Returns `true` if `f` is either `sin` or `cos`, `false` otherwise.
23+
"""
324
function trig_reduce(x)
425
x = add_div(x) # a/b + c/d = (ad + bc)/bd
526
x = expand(x) # open all brackets
@@ -19,8 +40,24 @@ function is_trig(f::Num)
1940
end
2041

2142
"""
22-
$(TYPEDSIGNATURES)
23-
Returns the coefficient of cos(ωt) in `x`.
43+
fourier_cos_term(x, ω, t)
44+
45+
Extract the coefficient of cos(ωt) from the expression `x`.
46+
Used in Fourier analysis to find the cosine components of a periodic function.
47+
48+
# Arguments
49+
- `x`: The expression to analyze
50+
- `ω`: The angular frequency
51+
- `t`: The time variable
52+
"""
53+
54+
"""
55+
add_div(x)
56+
57+
Simplify fractions by combining terms with common denominators.
58+
Transforms expressions of the form a/b + c/d into (ad + bc)/bd.
59+
60+
Returns the simplified fraction as a `Num` type.
2461
"""
2562
function fourier_cos_term(x, ω, t)
2663
return _fourier_term(x, ω, t, cos)
@@ -30,13 +67,34 @@ end
3067
add_div(x) = wrap(Postwalk(add_with_div; maketerm=frac_maketerm)(unwrap(x)))
3168

3269
"""
33-
$(TYPEDSIGNATURES)
34-
Returns the coefficient of sin(ωt) in `x`.
70+
fourier_sin_term(x, ω, t)
71+
72+
Extract the coefficient of sin(ωt) from the expression `x`.
73+
Used in Fourier analysis to find the sine components of a periodic function.
74+
75+
# Arguments
76+
- `x`: The expression to analyze
77+
- `ω`: The angular frequency
78+
- `t`: The time variable
3579
"""
3680
function fourier_sin_term(x, ω, t)
3781
return _fourier_term(x, ω, t, sin)
3882
end
3983

84+
"""
85+
_fourier_term(x::Equation, ω, t, f)
86+
_fourier_term(x, ω, t, f)
87+
88+
Internal function to extract Fourier coefficients from expressions.
89+
Handles both equations and regular expressions, returning the coefficient
90+
of the specified trigonometric function f(ωt).
91+
92+
# Arguments
93+
- `x`: The expression or equation to analyze
94+
- `ω`: The angular frequency
95+
- `t`: The time variable
96+
- `f`: The trigonometric function (sin or cos)
97+
"""
4098
function _fourier_term(x::Equation, ω, t, f)
4199
return Equation(_fourier_term(x.lhs, ω, t, f), _fourier_term(x.rhs, ω, t, f))
42100
end
@@ -51,7 +109,15 @@ function _fourier_term(x, ω, t, f)
51109
return Symbolics.expand(ft)
52110
end
53111

54-
"Convert all sin/cos terms in `x` into exponentials."
112+
113+
"""
114+
trig_to_exp(x::Num)
115+
116+
Convert all trigonometric terms (sin, cos) in expression `x` to their exponential form
117+
using Euler's formula: ``\\exp(ix) = \\cos(x) + i*\\sin(x)``.
118+
119+
Returns the converted expression as a `Num` type.
120+
"""
55121
function trig_to_exp(x::Num)
56122
all_terms = get_all_terms(x)
57123
trigs = filter(z -> is_trig(z), all_terms)
@@ -82,6 +148,22 @@ end
82148
convert_to_Num(x::Complex{Num})::Num = Num(first(x.re.val.arguments))
83149
convert_to_Num(x::Num)::Num = x
84150

151+
"""
152+
exp_to_trig(x::BasicSymbolic)
153+
exp_to_trig(x)
154+
exp_to_trig(x::Num)
155+
exp_to_trig(x::Complex{Num})
156+
157+
Convert exponential expressions to their trigonometric form using
158+
the inverse of Euler's formula:
159+
``\\cos(x) = (\\exp(ix) + \\exp(-ix))/2``
160+
and
161+
``\\sin(x) = (\\exp(ix) - \\exp(-ix))/(2i)``.
162+
163+
Handles various input types including basic symbolic expressions,
164+
complex numbers, and `Num` types. Standardizes the sign of
165+
trigonometric arguments for consistent simplification.
166+
"""
85167
function exp_to_trig(x::BasicSymbolic)
86168
if isadd(x) || isdiv(x) || ismul(x)
87169
return _apply_termwise(exp_to_trig, x)

0 commit comments

Comments
 (0)