11using Markdown
2- function first_steps (name, solver)
3- Markdown. parse (""" ## Installation
2+ function first_steps (name, solver; fixed_timesteps = false )
3+ sym_name = Symbol (name)
4+ sym_solver = Symbol (solver)
5+ @eval begin
6+ using $ sym_name
7+ function lorenz! (du, u, p, t)
8+ du[1 ] = 10.0 * (u[2 ] - u[1 ])
9+ du[2 ] = u[1 ] * (28.0 - u[3 ]) - u[2 ]
10+ du[3 ] = u[1 ] * u[2 ] - (8 / 3 ) * u[3 ]
11+ end
12+ u0 = [1.0 ; 0.0 ; 0.0 ]
13+ tspan = (0.0 , 100.0 )
14+ prob = ODEProblem (lorenz!, u0, tspan)
15+ if ! ($ fixed_timesteps)
16+ sol = solve (prob, ($ sym_solver)())
17+ else
18+ sol = solve (prob, ($ sym_solver)(), dt = 1 / 100 )
19+ end
20+ sol_end = sol[end ]
21+ end
22+ installation = """ ## Installation
423 To be able to access the solvers in `$name `, you must first install them use the Julia package manager:
524
625 ```julia
@@ -10,20 +29,53 @@ function first_steps(name, solver)
1029 This will only install the solvers listed at the bottom of this page.
1130 If you want to explore other solvers for your problem,
1231 you will need to install some of the other libraries listed in the navigation bar on the left.
32+ """
33+ example = if ! fixed_timesteps
34+ """
1335
14- ## Example usage
36+ ## Example usage
1537
16- ```julia
17- using $name
38+ ```julia
39+ using $name
1840
19- function lorenz!(du, u, p, t)
20- du[1] = 10.0 * (u[2] - u[1])
21- u[2] = u[1] * (28.0 - u[3]) - u[2]
22- du[3] = u[1] * u[2] - (8 / 3) * u[3]
41+ function lorenz!(du, u, p, t)
42+ du[1] = 10.0 * (u[2] - u[1])
43+ du[2] = u[1] * (28.0 - u[3]) - u[2]
44+ du[3] = u[1] * u[2] - (8 / 3) * u[3]
45+ end
46+ u0 = [1.0; 0.0; 0.0]
47+ tspan = (0.0, 100.0)
48+ prob = ODEProblem(lorenz!, u0, tspan)
49+ sol = solve(prob, $solver ())
50+ sol[end]
51+ ```
52+ ```julia
53+ $sol_end
54+ ```
55+ """
56+ else
57+ """
58+
59+ ## Example usage
60+
61+ ```julia
62+ using $name
63+
64+ function lorenz!(du, u, p, t)
65+ du[1] = 10.0 * (u[2] - u[1])
66+ du[2] = u[1] * (28.0 - u[3]) - u[2]
67+ du[3] = u[1] * u[2] - (8 / 3) * u[3]
68+ end
69+ u0 = [1.0; 0.0; 0.0]
70+ tspan = (0.0, 100.0)
71+ prob = ODEProblem(lorenz!, u0, tspan)
72+ sol = solve(prob, $solver (), dt=1/100)
73+ sol[end]
74+ ```
75+ ```julia
76+ $sol_end
77+ ```
78+ """
2379 end
24- u0 = [1.0; 0.0; 0.0]
25- tspan = (0.0, 100.0)
26- prob = ODEProblem(lorenz!, u0, tspan)
27- sol = solve(prob, $solver ())
28- ```""" )
80+ Markdown. parse (installation* example)
2981end
0 commit comments