Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
80 changes: 76 additions & 4 deletions tutorials/exercises/02-workshop_solutions.jmd
Original file line number Diff line number Diff line change
Expand Up @@ -192,6 +192,40 @@ plot(sol, xscale=:log10, tspan=(1e-6, 1e5), layout=(3,1))
```

## Part 3: Manual Index Reduction of the Single Pendulum
Consider the equation:
$$
x^2 + y^2 = L
$$
Differentiating once with respect to time:
$$
2x\dot{x} + 2y\dot{y} = 0
$$
A second time:
$$
\begin{align}
{\dot{x}}^2 + x\ddot{x} + {\dot{y}}^2 + y\ddot{y} &= 0 \\
u^2 + v^2 + x(\frac{x}{mL}T) + y(\frac{y}{mL}T - g) &= 0 \\
u^2 + v^2 + \frac{x^2 + y^2}{mL}T - yg &= 0 \\
u^2 + v^2 + \frac{T}{m} - yg &= 0
\end{align}
$$

Our final set of equations is hence
$$
\begin{align}
\ddot{x} &= \frac{x}{mL}T \\
\ddot{y} &= \frac{y}{mL}T - g \\
\dot{x} &= u \\
\dot{y} &= v \\
u^2 + v^2 -yg + \frac{T}{m} &= 0
\end{align}
$$

We finally obtain $T$ into the third equation.
This required two differentiations with respect
to time, and so our system of equations went from
index 3 to index 1. Now our solver can handle the
index 1 system.

## Part 4: Single Pendulum Solution with IDA
```julia
Expand Down Expand Up @@ -223,10 +257,46 @@ plot(sol, vars=(3,4))
```

## Part 5: Solving the Double Penulum DAE System
```julia
```

# Problem 4: Performance Optimizing and Parallelizing Semilinear PDE Solvers (I)
For the double pendulum:
The equations for the second ball are the same
as the single pendulum case. That is, the equations
for the second ball are:
$$
\begin{align}
\ddot{x_2} &= \frac{x_2}{m_2L_2}T_2 \\
\ddot{y_2} &= \frac{y_2}{m_2L_2}T_2 - g \\
\dot{x_2} &= u \\
\dot{y_2} &= v \\
u_2^2 + v_2^2 -y_2g + \frac{T_2}{m_2} &= 0
\end{align}
$$
For the first ball, consider $x_1^2 + y_1^2 = L $
$$
\begin{align}
x_1^2 + x_2^2 &= L \\
2x_1\dot{x_1} + 2y_1\dot{y_1} &= 0 \\
\dot{x_1}^2 + \dot{y_1}^2 + x_1(\frac{x_1}{m_1L_1}T_1 - \frac{x_2}{m_1L_2}T_2) + y_1(\frac{y_1}{m_1L_1}T_1 - g - \frac{y_2}{m_1L_2}T_2) &= 0 \\
u_1^2 + v_1^2 + \frac{T_1}{m_1} - \frac{x_1x_2 + y_1y_2}{m_1L_2}T_2 &= 0
\end{align}
$$

So the final equations are:
$$
\begin{align}
\dot{u_2} &= x_2*T_2/(m_2*L_2)
\dot{v_2} &= y_2*T_2/(m_2*L_2) - g
\dot{x_2} &= u_2
\dot{y_2} &= v_2
u_2^2 + v_2^2 -y_2*g + \frac{T_2}{m_2} &= 0

\dot{u_1} &= x_1*T_1/(m_1*L_1) - x_2*T_2/(m_2*L_2)
\dot{v_1} &= y_1*T_1/(m_1*L_1) - g - y_2*T_2/(m_2*L_2)
\dot{x_1} &= u_1
\dot{y_1} &= v_1
u_1^2 + v_1^2 + \frac{T_1}{m_1} +
\frac{-x_1*x_2 - y_1*y_2}{m_1L_2}T_2 - y_1g &= 0
\end{align}
$$
```julia
function f(out, da, a, p, t)
L1, m1, L2, m2, g = p
Expand Down Expand Up @@ -271,6 +341,8 @@ sol = solve(prob, IDA())
plot(sol, vars=(3,4))
plot(sol, vars=(8,9))
```

# Problem 4: Performance Optimizing and Parallelizing Semilinear PDE Solvers (I)
## Part 1: Implementing the BRUSS PDE System as ODEs

```julia
Expand Down