ConservationLawsParticles.DiffusiveIntegratedModelType
DiffusiveIntegratedModel((V₁, ...), ((W₁₁, ...), ...), (mob₁, ...), (D₁, ...))

Represents a particles system with:

  • external velocities Vᵢ,
  • integrated interactions Wᵢⱼ (this is the effect of the species j on the species i),
  • mobilities mobᵢ,
  • diffusions Dᵢ.

See also DiffusiveSampledModel.

Examples

julia> using ConservationLawsParticles.Examples, RecursiveArrayTools

julia> model = DiffusiveIntegratedModel(
           (V, V),
           ((W_attr, W_rep),
            (W_rep, W_attr)),
           (mobρ, mobσ),
           (Diffusion(1), nothing));

julia> x = ArrayPartition(gaussian_particles(2, 4), collect(range(-3, 4, length=5)))
([-2.000000000000003, -0.30305473018369145, 0.30305473018369145, 2.000000000000003], [-3.0, -1.25, 0.5, 2.25, 4.0])

julia> velocities_diff(x, model, 0.)
([6.032353228461558, -0.7551163082821832, 0.6338610075015758, -6.3250083138486275], [23.261098611816987, 0.9023583690557855, 0.7055593913708742, -8.774526834146023, -55.23308442021724])
ConservationLawsParticles.DiffusiveSampledModelType
DiffusiveSampledModel((V₁, ...), ((W′₁₁, ...), ...), (mob₁, ...), (D₁, ...))

Represents a particles system with:

  • external velocities Vᵢ,
  • sampled interactions W′ᵢⱼ (this is the effect of the species j on the species i),
  • mobilities mobᵢ,
  • diffusions Dᵢ.

See also DiffusiveIntegratedModel.

Examples

julia> using ConservationLawsParticles.Examples, RecursiveArrayTools

julia> model = DiffusiveSampledModel(
           (V, V),
           ((Wprime_attr, Wprime_rep),
            (Wprime_rep, Wprime_attr)),
           (mobρ, mobσ),
           (Diffusion(1), nothing));

julia> x = ArrayPartition(gaussian_particles(2, 4), collect(range(-3, 4, length=5)))
([-2.000000000000003, -0.30305473018369145, 0.30305473018369145, 2.000000000000003], [-3.0, -1.25, 0.5, 2.25, 4.0])

julia> velocities_diff(x, model, 0.)
([5.701842050142524, -0.8139064918316994, 0.3386810988127882, -6.637012508114956], [22.405129478914613, 1.1249366684885518, 1.5188519354999799, -7.87111869358889, -54.536397957423915])
ConservationLawsParticles.HyperbolicModelType
HyperbolicModel((V₁, ...), ((I₁₁, ...), ...), (mob₁, ...))

Represents a particles system with:

  • external velocities Vᵢ,
  • integrated interactions Iᵢⱼ (this is the effect of the species j on the species i),
  • mobilities mobᵢ.

See also ParabolicModel.

Examples

julia> using ConservationLawsParticles.Examples, RecursiveArrayTools

julia> model = HyperbolicModel(
           (V, V),
           ((SampledInteraction(Wprime_attr), IntegratedInteraction(W_rep)),
            (IntegratedInteraction(W_rep), SampledInteraction(Wprime_attr))),
           (mobρ, mobσ));

julia> x = ArrayPartition(gaussian_particles(2, 4), collect(range(-3, 4, length=5)))
([-2.000000000000003, -0.30305473018369145, 0.30305473018369145, 2.000000000000003], [-3.0, -1.25, 0.5, 2.25, 4.0])

julia> abstract_velocities(x, model, 0.)
([6.267901451064502, 0.2629261335925302, -0.3841814343731375, -6.560556536451573], [22.921033907881895, 0.8199108735979148, 0.7055593913708742, -8.681409489341364, -54.89301971628215])
ConservationLawsParticles.IntegratedModelType
IntegratedModel((V₁, ...), ((W₁₁, ...), ...), (mob₁, ...))

Represents a particles system with:

  • external velocities Vᵢ,
  • integrated interactions Wᵢⱼ (this is the effect of the species j on the species i),
  • mobilities mobᵢ.

See also SampledModel.

Examples

julia> using ConservationLawsParticles.Examples, RecursiveArrayTools

julia> model = IntegratedModel(
           (V, V),
           ((W_attr, W_rep),
            (W_rep, W_attr)),
           (mobρ, mobσ));

julia> x = ArrayPartition(gaussian_particles(2, 4), collect(range(-3, 4, length=5)))
([-2.000000000000003, -0.30305473018369145, 0.30305473018369145, 2.000000000000003], [-3.0, -1.25, 0.5, 2.25, 4.0])

julia> velocities(x, model, 0.)
([6.621647425385332, 0.30545649966452776, -0.42671180044513507, -6.914302510772401], [23.261098611816987, 0.9023583690557855, 0.7055593913708742, -8.774526834146023, -55.23308442021724])
ConservationLawsParticles.ParabolicModelType
ParabolicModel((V₁, ...), ((I₁₁, ...), ...), (mob₁, ...), (D₁, ...))

Represents a particles system with:

  • external velocities Vᵢ,
  • interactions Iᵢⱼ (this is the effect of the species j on the species i),
  • mobilities mobᵢ,
  • diffusions Dᵢ.

See also HyperbolicModel.

Examples

julia> using ConservationLawsParticles.Examples, RecursiveArrayTools

julia> model = ParabolicModel(
           (V, V),
           ((SampledInteraction(Wprime_attr), IntegratedInteraction(W_rep)),
            (IntegratedInteraction(W_rep), SampledInteraction(Wprime_attr))),
           (mobρ, mobσ),
           (Diffusion(1), nothing));

julia> x = ArrayPartition(gaussian_particles(2, 4), collect(range(-3, 4, length=5)))
([-2.000000000000003, -0.30305473018369145, 0.30305473018369145, 2.000000000000003], [-3.0, -1.25, 0.5, 2.25, 4.0])

julia> abstract_velocities(x, model, 0.)
([5.678607254140728, -0.7976466743541808, 0.6763913735735734, -5.971262339527799], [22.921033907881895, 0.8199108735979148, 0.7055593913708742, -8.681409489341364, -54.89301971628215])
ConservationLawsParticles.SampledModelType
SampledModel((V₁, ...), ((W′₁₁, ...), ...), (mob₁, ...))

Represents a particles system with:

  • external velocities Vᵢ,
  • sampled interactions W′ᵢⱼ (this is the effect of the species j on the species i),
  • mobilities mobᵢ.

See also IntegratedModel.

Examples

julia> using ConservationLawsParticles.Examples, RecursiveArrayTools

julia> model = SampledModel(
           (V, V),
           ((Wprime_attr, Wprime_rep),
            (Wprime_rep, Wprime_attr)),
           (mobρ, mobσ));

julia> x = ArrayPartition(gaussian_particles(2, 4), collect(range(-3, 4, length=5)))
([-2.000000000000003, -0.30305473018369145, 0.30305473018369145, 2.000000000000003], [-3.0, -1.25, 0.5, 2.25, 4.0])

julia> velocities(x, model, 0.)
([6.291136247066298, 0.2466663161150116, -0.7218917091339228, -7.22630670503873], [22.405129478914613, 1.1249366684885518, 1.5188519354999799, -7.87111869358889, -54.536397957423915])
ConservationLawsParticles.gaussian_particlesMethod
gaussian_particles(width::Real, number::Integer)

Generates number particles defining a Gaussian distribution with variance 1/2 truncated to the interval [-width, width].

ConservationLawsParticles.integrated_interactionFunction
integrated_interaction([t,] x, W, ys[, dens_diff])

Computes $-(W' * \rho)(t, x) = -(W * \rho')(t,x)$, where $\rho$ is the piecewise-constant density associated to the particles ys.

It t is omitted, then W(x) is assumed independent of time.

Note

To ensure the correctness of the computation, dens_diff must coincide with diff(pwc_density(ys)). It can be pre-computed and passed explicitly to allow reuse (as an optimization).

See also sampled_interaction, compute_interaction.

ConservationLawsParticles.make_velocitiesMethod
make_velocities((V₁, ...), ((W′₁₁, ...), ...), (mob₁, ...))

Creates a function velocities(dx, x, p, t) that computes the velocity of the particles under the influence of the external velocities Vᵢ, mutual interactions W′ᵢⱼ and congestions given by mobᵢ.

See also make_velocity.

ConservationLawsParticles.make_velocityMethod
make_velocity(V::Function, Wprime::Function, mobility::Function)

Creates a function velocity(dx, x, p, t) that computes the velocity of the particles under the influence of an external velocity V, a mutual interaction Wprime and the congestion given by mobility.

See also make_velocities.

ConservationLawsParticles.pwc_densitiesFunction
pwc_densities(xs::AbstractVector{<:Real}...)
pwc_densities(xs::Tuple{Vararg{AbstractVector{<:Real}}})

Given a list of n families of particles of lengths l₁, …, lₙ, returns an n-tuple whose s-th entry is an n×2×lₛ array densₛ.

This array contains the information about the densities of all the species around the particles of the s-th species. This array is indexed as [o,side,i], where o∈{1, …, n} is the index of the other species whose density we want to know, side is either 1 if we want to know the left density or 2 for the right density, and i∈{1, …, lₛ} is the index of the particle.

In other words, densₛ[o,side,i] is the density of the o-th species on the left (side=1) or right (side=2) of the i-th particle of the s-th species.

See also pwc_densities! for an inplace version.

Examples

julia> pwc_densities([0,1,2], [0,2,3])
([0.0 0.5; 0.0 0.25;;; 0.5 0.5; 0.25 0.25;;; 0.5 0.0; 0.25 0.5], [0.0 0.5; 0.0 0.25;;; 0.5 0.0; 0.25 0.5;;; 0.0 0.0; 0.5 0.0])
ConservationLawsParticles.pwc_densityMethod
pwc_density(x::AbstractVector)

Returns the piecewise constant probability density from the quantile particle positions.

Let the quantile particles be at positions x₀, x₁, …, xₙ (remember that in Julia they are actually x[1], x[2], ..., x[n], x[n+1]). The returned array R is such that R[1] = R[n+2] = 0 and R[i] = 1 / (N * (x[i] - x[i-1])) for the intermediate indices (this formula holds also for the first and last entry if we assume x[0] = -∞ and x[n+2] = ∞).

Examples

julia> pwc_density([0, 1, 3])
4-element Vector{Float64}:
 0.0
 0.5
 0.25
 0.0
ConservationLawsParticles.@time_independentMacro

Automatically define a method which takes time as first argument and discards it.

Examples

The definition

@time_independent V(x) = -x^3

is equivalent to

V(x) = -x^3
V(t, x) = V(x)

This also works with more than one argument, for instance

@time_independent V(x₁, x₂) = x₁ * x₂

is equivalent to

V(x₁, x₂) = x₁ * x₂
V(t, x₁, x₂) = V(x₁, x₂)