Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add tutorial for setting up a simulation #514

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open

Conversation

efaulhaber
Copy link
Member

@efaulhaber efaulhaber commented May 3, 2024

@efaulhaber efaulhaber added the documentation Improvements or additions to documentation label May 3, 2024
@efaulhaber efaulhaber requested review from svchb and LasNikas May 3, 2024 22:00
Copy link
Collaborator

@svchb svchb left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks. This also needs some suggestions for which modifications can be made to see some other results. For example moving the initial fluid up 0.1...

Comment on lines +15 to +22
At the beginning of most simulation files, we define the numerical resolution,
so that it can easily be found and changed.
First, we import TrixiParticles.jl and
[OrdinaryDiffEq.jl](https://github.com/SciML/OrdinaryDiffEq.jl), which we will
use at the very end for the time integration.
```jldoctest tut_setup; output = false
using TrixiParticles
using OrdinaryDiffEq
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This needs:

  1. What does numerical resolution mean here?
  2. What is the common name that we use?
  3. What impact does that have?
  4. Concrete values for the example that you are discussing.
    ...

Comment on lines +28 to +31
We also set the number of boundary layers, which need to be sufficiently
large, depending on the smoothing kernel and smoothing length, so that
the compact support of the smoothing kernel is fully sampled with particles
for a fluid particle close to a boundary.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This would be much more concrete if you would just write compact_support < boundary layers and give here the common values for the compact support or how one can find them.


# output
1000.0
```
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add a drawing.

Comment on lines +115 to +124
For stability, we need numerical dissipation in form of an artificial viscosity
term.
```jldoctest tut_setup; output = false
viscosity = ArtificialViscosityMonaghan(alpha=0.02, beta=0.0)

# output
ArtificialViscosityMonaghan{Float64}(0.02, 0.0, 0.01)
```
We choose the parameters as small as possible to avoid visible viscosity,
but as large as possible to stabilize the simulation.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is formulated in a way that the only reason to use this type of viscosity is for stability reasons, which is not true it needs to be set according to the viscosity of the fluid to be simulated. It should also be mentioned here that beta is usually 0.0 in fluid simulations.

Comment on lines +126 to +130
The WCSPH method can either compute the particle density by a kernel summation
over all neighboring particles (see [`SummationDensity`](@ref)) or by making
the particle density a variable in the ODE system and integrating it over time.
We choose the latter approach here by using the density calculator
[`ContinuityDensity`](@ref).
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should also shortly mention the pro/cons of these methods.

Comment on lines +158 to +160
We will use the [`BoundaryModelDummyParticles`](@ref) with
[`AdamiPressureExtrapolation`](@ref), which generally produces the best results
of the implemented methods.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since we don't know which methods will still be implemented this should be formulated more neutrally.


The key component of every simulation is the [`Semidiscretization`](@ref),
which couples all systems of the simulation.
All methods in TrixiParticles.jl are semidiscretizations, which discretize
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All methods? That is a bit too general.

```

See [Visualization](@ref) for how to visualize the solution.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add image here

Copy link
Collaborator

@LasNikas LasNikas left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks a lot!

It would be nice to have a sketch of the tank at the very beginning. Also, a short description (or also sketch?) how we usually structure our example files.


```
Now, we define the particle spacing, which is our numerical resolution.
We also set the number of boundary layers, which need to be sufficiently
large, depending on the smoothing kernel and smoothing length, so that
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

link to the corresponding doc section

Comment on lines +17 to +19
First, we import TrixiParticles.jl and
[OrdinaryDiffEq.jl](https://github.com/SciML/OrdinaryDiffEq.jl), which we will
use at the very end for the time integration.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

put this somewhere above the section ## Resolution?


For different setups and physics, have a look at [our other example files](@ref examples).
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe explain how we usually structure our example files. Resolution, experiment setup, ...

Comment on lines +44 to +45
First, we define the physical parameters gravitational acceleration,
initial fluid size, tank size, fluid density, and simulation time.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
First, we define the physical parameters gravitational acceleration,
initial fluid size, tank size, fluid density, and simulation time.
First, we define the physical parameters gravitational acceleration, simulation time, initial fluid size, tank size and fluid density.

Comment on lines +58 to +59
hydrostatic pressure gradient, we need to define a state equation, which
relates the fluid density to pressure.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

link to docs?

Comment on lines +156 to +158
In order to define a boundary system, we first have to choose a boundary model,
which defines how the fluid interacts with boundary particles.
We will use the [`BoundaryModelDummyParticles`](@ref) with
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It might make sense to mention that the BC in SPH are modeled numerically with particles instead of having an analytical described surface

information about the current simulation time and runtime during the simulation,
and a performance summary at the end of the simulation.
We also want to save the current solution in regular intervals in terms of
simulation time as VTK, so that we can look at the solution in ParaView.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

link to the visualization section

simulation time as VTK, so that we can look at the solution in ParaView.
The [`SolutionSavingCallback`](@ref) provides this functionality.
To pass the callbacks to OrdinaryDiffEq.jl, we have to bundle them into a
`CallbackSet`.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

link CallbackSet to the corresponding doc page in SciML?

Comment on lines +222 to +223
Finally, we can start the simulation by solving the `ODEProblem`.
We use the method `RDPK3SpFSAL35` of OrdinaryDiffEq.jl, which is a Runge-Kutta
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

links?

Comment on lines +299 to +300
# output

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maybe add something like plot(my_kernel) to visualize the Kernel in 1D (or more fancy in 2D)?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation Improvements or additions to documentation
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants