Quick Start

This tutorial runs through setting up a basic particle field and simulating the field.

Create a ParticleField

First, we create a particle field with a maximum of 10 particles.

using FLOWVPM

max_particles = 10
pfield = ParticleField(max_particles);
ParticleField{Float64, ReformulatedVPM{Float64}, FLOWVPM.Inviscid{Float64}, typeof(FLOWVPM.nofreestream), NoSFS{Float64, typeof(FLOWVPM.null_model)}, FLOWVPM.Kernel{typeof(FLOWVPM.zeta_gauserf), typeof(FLOWVPM.g_gauserf), typeof(FLOWVPM.dgdr_gauserf), typeof(FLOWVPM.g_dgdr_gauserf)}, typeof(FLOWVPM.UJ_fmm), typeof(FLOWVPM.rungekutta3), FLOWVPM.Relaxation{Float64, typeof(FLOWVPM.relax_pedrizzetti)}, 0}(10, [0.0 0.0 … 0.0 0.0; 0.0 0.0 … 0.0 0.0; … ; 0.0 0.0 … 0.0 0.0; 0.0 0.0 … 0.0 0.0], ReformulatedVPM{Float64}(0.0, 0.2, 0.3999999999999999), FLOWVPM.Inviscid{Float64}(0.0), 0, 0, 0.0, FLOWVPM.Kernel{typeof(FLOWVPM.zeta_gauserf), typeof(FLOWVPM.g_gauserf), typeof(FLOWVPM.dgdr_gauserf), typeof(FLOWVPM.g_dgdr_gauserf)}(FLOWVPM.zeta_gauserf, FLOWVPM.g_gauserf, FLOWVPM.dgdr_gauserf, FLOWVPM.g_dgdr_gauserf), FLOWVPM.UJ_fmm, FLOWVPM.nofreestream, NoSFS{Float64, typeof(FLOWVPM.null_model)}(FLOWVPM.null_model), FLOWVPM.rungekutta3, true, FLOWVPM.Relaxation{Float64, typeof(FLOWVPM.relax_pedrizzetti)}(FLOWVPM.relax_pedrizzetti, 1, 0.3), FLOWVPM.FMM(4, 10, 0.5, true, 0.001, 0.001, true, true, true, 1.0), 0, [0.0, 0.0, 0.0, 0.0])

This creates an empty particle field that holds at most 10 particles.

Add Particles

Now we can add particles to the field. Attempting to add more than max_particles will result in an error.

using Random

for i in 1:max_particles
    add_particle(pfield, rand(3), rand(3), rand(1)[1])
end
println("Number of particles: ", pfield.np)
Number of particles: 10

Propogate the ParticleField

The particles in the ParticleField can be propogated single steps using FLOWVPM.nextstep(pfield, dt).

dt = 0.01
FLOWVPM.nextstep(pfield, dt)
1

For convinence run_vpm!(pfield, dt, nsteps) is also provided.

dt = 0.01
nsteps = 100
run_vpm!(pfield, dt, nsteps)
-------------------------------------------------------------------------

	SOLVER SETTINGS
		  maxparticles----> 10
		   formulation----> formulation_rVPM
		       viscous----> (Symbol("*userfunction"), "FLOWVPM.Inviscid{Float64}(0.0)")
		        kernel----> gaussianerf
		            UJ----> UJ_fmm
		          Uinf----> nofreestream
		           SFS----> SFS_none
		   integration----> rungekutta3
		    transposed----> true
		    relaxation----> pedrizzetti
		           fmm----> FLOWVPM.FMM(2, 1, 0.5, true, 0.001, 0.001, true, true, true, 1.0)
		        useGPU----> 0

	SIMULATION SETTINGS
		dt:			0.01
		Runtime function:	Nothing
		Static particles:	Nothing
		nsteps_save:		1

-------------------------------------------------------------------------
*************************************************************************
START
	2025-08-05T12:11:32.249
*************************************************************************
	Time step 0 out of 100	Particles: 10
	Time step 10 out of 100	Particles: 10
	Time step 20 out of 100	Particles: 10
	Time step 30 out of 100	Particles: 10
	Time step 40 out of 100	Particles: 10
	Time step 50 out of 100	Particles: 10
	Time step 60 out of 100	Particles: 10
	Time step 70 out of 100	Particles: 10
	Time step 80 out of 100	Particles: 10
	Time step 90 out of 100	Particles: 10
	Time step 100 out of 100	Particles: 10
*************************************************************************
END
	2025-08-05T12:11:32.272
*************************************************************************
ELAPSED TIME: 0 hours 0 minutes 0 seconds

Remove Particles

If we want to remove particles from the field we can use the remove_particle(pfield, i) function where i is the index of the particle we want removed.

for i in pfield.np:-1:1
    remove_particle(pfield, i)
end
println("Number of particles after removal ", pfield.np)
Number of particles after removal 0