Skip to content

Commit

Permalink
Improve consistency
Browse files Browse the repository at this point in the history
  • Loading branch information
Uwe Fechner committed Dec 13, 2023
1 parent 58474df commit 030192a
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 13 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ If you compare the Python and the Julia script you can see that:

Have a look at the [Examples] that teach you how to construct a full tether model step by step.

## Comparison
## Overall comparison
Execution time for a simulation of 10s duration with logging the state every 20ms.

| Testcase | Lines of code (LOC) Julia | LOC Python | Time Julia [ms] | Time Python [ms] |
Expand Down
13 changes: 6 additions & 7 deletions docs/src/examples.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
## More examples
### Mass, attached to a spring damper element
## Mass, attached to a spring damper element
From the Julia prompt, run the simulation:
```julia
include("src/Tether_02.jl")
Expand All @@ -12,7 +11,7 @@ upwards.

**Julia code:** [Tether_02.jl](src/Tether_02.jl)

### Mass, attached to a non-linear spring damper element
## Mass, attached to a non-linear spring damper element
```julia
include("src/Tether_03.jl")
```
Expand Down Expand Up @@ -40,7 +39,7 @@ eqs = vcat(D.(pos) ~ vel,

The same as Python version: **Python code:** [Tether_03.py](src/Tether_03.py).

#### Using a callback
### Using a callback
By using a callback to detect exactly when the transition from a stiff tether segment to a loose
tether segment happens we can increase the accuracy of the simulation. **Julia code:** [Tether_03b.jl](src/Tether_03b.jl).

Expand All @@ -59,7 +58,7 @@ and add the parameter `callback = cb` to the line that calls the solver:
sol = solve(prob, Rodas5(), dt=dt, abstol=tol, reltol=tol, saveat=ts, callback = cb)
```

#### Using a callback with Python
### Using a callback with Python
In Python you would have to add the following attribute:
```Python
sw0 = [vel_1[2] > 0] # array of booleans; true means the tether segment is loose (l < l_0)
Expand Down Expand Up @@ -90,7 +89,7 @@ As you can see, logging of calculated variables is not
possible with Assimulo (easy with ModelingToolkit in Julia). You need to re-calculate them
after the simulation.

#### Multi-segment tether
## Multi-segment tether
Using 2D arrays of variables allows to simulate a multi-segment tether:
```julia
@variables pos(t)[1:3, 1:segments+1] = POS0
Expand Down Expand Up @@ -137,7 +136,7 @@ Finally in this example we plot the result dynamically as 2D video. Screenshot:
![Tether 2D](docs/images/Tether2d.png)


#### Benchmarking
## Benchmarking
Using a callback slows the simulation down, but not much. Try it out:
```julia
include("src/Tether_03c.jl")
Expand Down
10 changes: 5 additions & 5 deletions docs/src/python.md
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
## Python and Julia in harmony
# Python and Julia in harmony

Python and Julia play very well together. You could see in the examples above that I am using Matplotlib for plotting, both in Python and in Julia. Julia has a build-in package manager. You can use it install and remove Julia packages, but also to install or remove Python packages. That works like this:

### Using Python packages from Julia
## Using Python packages from Julia
There are three options:

#### Option one:
### Option one:
Use wrapper libraries which exist for a few, very popular Python packages, e.g.
[PyPlot.jl](https://github.com/JuliaPy/PyPlot.jl) for Matplotlib or [SymPy.jl](https://github.com/JuliaPy/SymPy.jl) for SymPy. You can install them like any other Julia package, e.g.
```
Expand All @@ -18,7 +18,7 @@ and on the Julia prompt:
using SymPy
```

#### Option two:
### Option two:

Use PyCall to use Python packages for Julia. This works for all Python packages, but
is a little bit less comfortable than option one. Example:
Expand Down Expand Up @@ -46,7 +46,7 @@ cd bin
```
to re-build it.

#### Option three:
### Option three:

Using the package [PythonCall](https://github.com/JuliaPy/PythonCall.jl).
You cannot use it together with `PyCall`, it is the newer successor of `PyCall`, and it is
Expand Down

0 comments on commit 030192a

Please sign in to comment.