Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
147 commits
Select commit Hold shift + click to select a range
be2b118
doc fixes
knstmrd Feb 6, 2026
475f265
v0.7.8
knstmrd Feb 6, 2026
18126e3
typo fix
knstmrd Feb 9, 2026
c80031b
1-factorization function for grouping chunks for multi-threaded parti…
knstmrd Feb 9, 2026
d5cc40a
typo fix
knstmrd Feb 22, 2026
81af6fe
Bolsig files for reference data generation
knstmrd Feb 22, 2026
7cc782e
docs update/fix
knstmrd Feb 22, 2026
b5aa0a0
fix of non-ES ionization routine
knstmrd Feb 24, 2026
c5cc244
ionization test (no event splitting)
knstmrd Feb 24, 2026
39e9e5a
current changes
knstmrd Feb 24, 2026
502738b
move order of cf and merge
knstmrd Feb 25, 2026
2f6889a
array access
knstmrd Feb 25, 2026
76a5934
new sampling routine + tests
knstmrd Feb 25, 2026
3879570
documentation update
knstmrd Feb 26, 2026
c8ebbda
switched order of merging and coll factor estimation, added pre-loop …
knstmrd Feb 26, 2026
2977c6c
changelog
knstmrd Feb 26, 2026
db5808e
n_t as parameter everywhere now
knstmrd Mar 2, 2026
2762d50
n_t just so that run_examples.py doesn't complain
knstmrd Mar 2, 2026
c65fc26
fixed example
knstmrd Mar 2, 2026
24cc950
test examples faster
knstmrd Mar 2, 2026
f9cfd30
fixed examples
knstmrd Mar 2, 2026
b5a22ef
notes on run_examples script
knstmrd Mar 2, 2026
7c1d02a
chunk-specific exchange for parallelized exchange
knstmrd Mar 4, 2026
e0cc66e
parallelized particle exchange now possible
knstmrd Mar 4, 2026
10ca516
overview of simulation files
knstmrd Mar 8, 2026
92b6033
notes on particle exchange
knstmrd Mar 8, 2026
2ca98ad
multithreaded notes update
knstmrd Mar 8, 2026
f562e72
fourier examples
knstmrd Mar 9, 2026
2dc6d49
NNLS exact RP merging
knstmrd Mar 9, 2026
61c457b
more notes on reproducibility
knstmrd Mar 10, 2026
af39e46
exact rate-conserving NNLS merge tests
knstmrd Mar 10, 2026
f612370
More notes on reproducibility
knstmrd Mar 10, 2026
70721e9
ionization + octree improved setup, but needs clean-up still
knstmrd Mar 10, 2026
e9fe2b5
ionization reference data for testing
knstmrd Mar 11, 2026
5b4c011
NNLS ionization reproducibility
knstmrd Mar 11, 2026
7bfc6df
octree ionization testcase description
knstmrd Mar 11, 2026
d08ec83
some more comments
knstmrd Mar 11, 2026
7b24389
now full setup for 0D ionization test case (NNLS)
knstmrd Mar 12, 2026
fd96c34
setup done for ionization cases
knstmrd Mar 12, 2026
4289fc4
BKW NNLS setup
knstmrd Mar 12, 2026
d3a7c8d
typos
knstmrd Mar 12, 2026
0e9445d
reproducibility simulation setups
knstmrd Mar 12, 2026
1f75135
comment out
knstmrd Mar 12, 2026
6490ee9
sample and merge simulation draft
knstmrd Mar 13, 2026
e49cdc6
fixed output file path
knstmrd Mar 14, 2026
a9fc287
estimate of file sizes
knstmrd Mar 16, 2026
0592dd7
notes on version
knstmrd Mar 16, 2026
252be5a
minor fixes/changes
knstmrd Mar 16, 2026
0d1b9bb
notes on reproducibility scripts
knstmrd Mar 16, 2026
bd45dd3
remove old code
knstmrd Mar 16, 2026
d3d08ab
fourier script
knstmrd Mar 16, 2026
bd81397
unused imports
knstmrd Mar 16, 2026
82d5209
indentation
knstmrd Mar 16, 2026
6548e93
typo fixes
knstmrd Mar 16, 2026
fdb61b7
filenames fix
knstmrd Mar 16, 2026
b56b12d
fourier script + readme update
knstmrd Mar 17, 2026
c723bfe
remove underscores
knstmrd Mar 17, 2026
34da727
script fixes
knstmrd Mar 17, 2026
2cc5331
correct avg_start
knstmrd Mar 17, 2026
6c36946
run the actual simulations
knstmrd Mar 17, 2026
d82fc39
docstring
knstmrd Mar 17, 2026
42cac82
docstrings
knstmrd Mar 17, 2026
c5c7781
readme update
knstmrd Mar 17, 2026
f091515
fixed n_t
knstmrd Mar 17, 2026
e42ed0c
ref values update
knstmrd Mar 17, 2026
a94600f
fixed old value of threshold
knstmrd Mar 17, 2026
a40b563
sample_and_merge setup
knstmrd Mar 17, 2026
11972a7
reference values
knstmrd Mar 17, 2026
e0fc521
setup so that run_examples.py works as expected
knstmrd Mar 17, 2026
69036bf
some explanations
knstmrd Mar 17, 2026
8394a03
Changelog update
knstmrd Mar 17, 2026
1276022
conversion script
knstmrd Mar 18, 2026
7cd313f
script notes
knstmrd Mar 18, 2026
6b31155
filename updates
knstmrd Mar 18, 2026
dc47d38
minor formatting
knstmrd Mar 18, 2026
b3de47b
fixed iteration over NNLS results
knstmrd Mar 18, 2026
37d578c
fixed unused imports
knstmrd Mar 18, 2026
b3c0efa
readme update
knstmrd Mar 18, 2026
68c6b9d
notes on scaling factor
knstmrd Mar 18, 2026
3184453
draft of file
knstmrd Mar 18, 2026
2b97c02
filename fixes
knstmrd Mar 18, 2026
6416729
write to scratch/data
knstmrd Mar 18, 2026
0c50343
empty line
knstmrd Mar 18, 2026
b36b876
turn off plot saving by default
knstmrd Mar 18, 2026
2cb4c7c
ionization processing script
knstmrd Mar 18, 2026
4db48d7
cleanup and docs
knstmrd Mar 18, 2026
b533559
notes on script
knstmrd Mar 18, 2026
cb54b82
update script to create missing scratch paths if necessary
knstmrd Mar 22, 2026
8321eca
cross_section_filepath as run function parameter
knstmrd Mar 22, 2026
eba6593
agents.md
knstmrd Mar 23, 2026
39e9abf
simulations Merzbild import fixed
knstmrd Mar 23, 2026
de684d5
fix n_t
knstmrd Mar 23, 2026
aec94d8
filepath to ionization DB
Mar 23, 2026
5061376
readme update
Mar 23, 2026
bf6d899
specify optional path to log files
Mar 23, 2026
e980d84
check presence of external data
Mar 23, 2026
66a32fd
uniform naming
Mar 23, 2026
6438a9d
write to file
Mar 23, 2026
df53e95
plotting script
Mar 23, 2026
d67577f
save plots on by default
Mar 23, 2026
d3baea2
sample and merge setup
Mar 23, 2026
55f1aea
sample-and-merge script notes
Mar 23, 2026
162a9a0
scratch/data notes
Mar 23, 2026
244d0c8
filename fix
Mar 23, 2026
a0441d1
readme update
Mar 23, 2026
4a432e8
skip runs just in case
Mar 23, 2026
5305f36
a single run is enough to distort stats on weight ratios
Mar 23, 2026
a5e21b2
simulation updates so that it actually runs stuff
Mar 23, 2026
1ecbb08
clearer output and updated readme
knstmrd Mar 24, 2026
865b3da
Int64 everywhere
knstmrd Mar 24, 2026
c4cab1c
v0.7.9-dev
knstmrd Mar 24, 2026
b02535f
octree optimizations
knstmrd Mar 24, 2026
8069063
fill!, Int64, etc.
knstmrd Mar 24, 2026
b558420
remove prints
knstmrd Mar 24, 2026
f6c12f5
added additional tests for correctness of buffers/indexing
knstmrd Mar 26, 2026
10b2040
fix Merzbild import
knstmrd Mar 27, 2026
052e619
move inbounds
knstmrd Mar 27, 2026
96cae0e
inbounds added
knstmrd Mar 27, 2026
63e1de6
move allocations together
knstmrd Mar 27, 2026
3af43e0
possible ntc speed-up + code unification
knstmrd Mar 27, 2026
33d9b33
Merge branch 'main' into v079-dev
knstmrd Apr 2, 2026
196fff1
doc for 2-particle collision, dw_tol param (untested)
knstmrd Apr 2, 2026
537b30e
tests for new collision function
Apr 7, 2026
0b1f121
slightly faster and cleaner neutral-electron collision code
Apr 7, 2026
d58edca
inbounds in acceleration
Apr 7, 2026
2c1f391
changelog
Apr 7, 2026
8698105
equal-weight collisions
Apr 8, 2026
2eb73e8
tolerances tightened up
Apr 8, 2026
67acb3f
make use of equal-weight collisions
Apr 8, 2026
09071c4
add new tests
Apr 8, 2026
bd1ae63
minor code clean-up
Apr 8, 2026
a1e543f
export new function
Apr 8, 2026
fa67b2f
docs
Apr 8, 2026
74cd425
changelog
Apr 8, 2026
bba542f
failing test (not producing ions)
Apr 8, 2026
5e7dd9e
ionization tests
Apr 8, 2026
75c3fd8
uncomment tests, add empty particle index sorting test
Apr 8, 2026
5fe102a
restore_particle_ordering! - untested for now
Apr 8, 2026
5c6c563
moved swap to particles.jl, restore_particle_ordering! fixed
Apr 9, 2026
acd12a8
restore_particle_ordering! tests + docs
Apr 9, 2026
fa39e10
restore_particle_ordering! test
Apr 9, 2026
b5a9747
fixed restore_ordering + additional tests
Apr 9, 2026
960d293
test for couette flow with re-sorting
Apr 9, 2026
7492685
add re-sorting
Apr 9, 2026
b3c7189
restore index order
Apr 9, 2026
2a26aa3
1D simulations now make use of restored indexing
Apr 9, 2026
1ae7bca
doc link fixes
Apr 9, 2026
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
12 changes: 12 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,17 @@
# Changelog

## v0.7.9
* `restore_particle_ordering!` added, this restores optimal indexing of particles and can lead to simulation speed-ups due to improved cache usage
* Minor optimizations in octree merging
* Simplified elastic VHS collision code via a unified `collide_2particles_vhs!` function, minor speed-ups
* New keyword parameter `dw_tol` in collision routines that sets tolerance in weight difference under which particle
collisions are treated as equal weight collisions and no additional particle splitting is performed
* Minor improvements in readability and speed of electron-neutral collision routines
* `@inbounds` added to acceleration routine
* `ntc_equal_weight` added for slightly faster collisions in equal-weight simulations
* Documentation improvements
* Improved test coverage

## v0.7.8
* Fixed ionization simulations without event splitting
* Tests for simulations with elastic and ionizing electron-neutral collisions (without event splitting)
Expand Down
2 changes: 1 addition & 1 deletion Project.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name = "Merzbild"
uuid = "de01fcb4-c117-45a4-a951-7e39b0f12516"
authors = ["Georgii Oblapenko <kunstmord@kunstmord.com>", "Leo Basov <basov.leo@gmail.com>"]
version = "0.7.8"
version = "0.7.9"

[deps]
ChunkSplitters = "ae650224-84b6-46f8-82ea-d812ca08434e"
Expand Down
5 changes: 5 additions & 0 deletions docs/src/contiguous_indexing.md
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,11 @@ the value of `pia.contiguous` and does nothing if that value is set to `true`.
**Summary**: one needs to restore continuity of particle indexing if particles are deleted and created in a simulation, otherwise this
might lead to erroneous results.

## Optimal particle indexing
Over time, particle indexing becomes quite fragmented, leading to poor cache performance. Especially in non-0D simulations this affects the performance
of sorting and convection routines. This can be fixed by calling [`restore_particle_ordering!`](@ref) **after** the particles have been sorted.
Restoring particle indexing every 10 timesteps seems to be a good balance between the cost of the re-indexing operation and the performance gain.

## Debugging
Several utility functions are available to verify/help debug simulations.

Expand Down
18 changes: 17 additions & 1 deletion docs/src/overview_1d.md
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,17 @@ sort_particles!(gridsorter, grid, particles[species_id], pia, species_id)
Since sorting indices only can lead to increase fragmentation of the particle layout in memory,
a function [`count_disordered_particles`](@ref) is available that counts the number of
non-continuously laid out particles; this can serve as a metric as to whether the underlying
particles (and not just their indices) need to be re-sorted (currently not implemented).
particles (and not just their indices) need to be re-sorted.
The fragmentation of particles indices can be fixed by calling [`restore_particle_ordering!`](@ref) after the sorting routine;
calling it every 10 timesteps or so gives a good balance between cost of re-indexing and speed-up due to improved memory access.

The re-indexing can be called as follows:
```julia
restore_particle_ordering!(particles[species_id], index_inv_map)
```

Here `index_inv_map` is a pre-allocated array of integers of length equal to the number of particles in the simulation (if it is smaller,
it will be resized in by the `restore_particle_ordering!` function).

## Creating boundary conditions
Next, we need to create boundary conditions for the left and right walls.
Expand Down Expand Up @@ -169,6 +179,7 @@ n_particles = ppc * nx
particles = [ParticleVector(n_particles)]
pia = ParticleIndexerArray(grid.n_cells, 1)
gridsorter = GridSortInPlace(grid, n_particles)
index_inv_map = zeros(Int64, n_particles)

# sample particles
# Fnum * ppc = Np in cell = ndens * V_cell
Expand Down Expand Up @@ -227,6 +238,11 @@ for t in 1:n_timesteps
# sort particles
sort_particles!(gridsorter, grid, particles[1], pia, 1)

# restore indexing/ordering every 10 timesteps
if t%10 == 0
restore_particle_ordering!(particles[1], index_inv_map)
end

# compute props and do averaging
if (t >= avg_start)
compute_props_sorted!(particles, pia, species_data, phys_props)
Expand Down
6 changes: 6 additions & 0 deletions docs/src/overview_blocks.md
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,12 @@ For all practical purposes, it should be sufficient to deal with particles in a
by directly accessing them as `pv[i]`; the `index` and `cell` fields need to be changed only when one is writing
new sorting routines.

**Important**: over the course of a simulation, as particles get re-sorted, deleted, created, or merged,
indexing may become sub-optimal; and particle access becomes cache-inefficient. This can be fixed by calling [`restore_particle_ordering!`](@ref),
it is up to the user to decide how frequently this should be done to balance the cost of re-indexing and particle access in other routines.
Example of such usage can be found in 1D simulations in `simulations/1D` (for example, in `simulations/1D/couette_varweight_octree.jl`).
Re-ordering indexing every 10 timesteps seems to be a good starting point.

For a more in-depth overview of particle indexing, especially relevant for multi-dimensional simulations
where particles might be frequently deleted due to merging or outflow, the reader is referred to
[the documentation on contiguous indexing](@ref "Contiguous indexing"), which describes additional
Expand Down
15 changes: 9 additions & 6 deletions docs/src/overview_fixedweight.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,11 +33,11 @@ passed to the collision routine, which will use it as required.

## NTC-specific data: CollisionFactors
The No-Time Counter (NTC) collision algorithm requires an estimate of ``(\sigma g w)_{max}`` for each species pair
for each cell in the flow. The `CollisionFactors` data structure stores the values of this factor, as well as
for each cell in the flow. The [`CollisionFactors`](@ref) data structure stores the values of this factor, as well as
other NTC-related parameters (number of collisions performed, number of collision partners).
One needs to initialize a 3-dimensional array of `CollisionFactors` of shape
`n_species x n_species x n_cells` in order to store the required factors for each species' pair for all cells in the flow;
this is done by calling `create_collision_factors_array(n_species, n_cells)`.
this is done by calling [`create_collision_factors_array(n_species, n_cells)`](@ref).
Some initial estimate for the values of ``(\sigma g w)_{max}``; the simplest way to do so for a fixed-weight DSMC simulation
is to call the `estimate_sigma_g_w_max!(collision_factors, interactions, species_data, T_list, Fnum; mult_factor=1.0)`
function.
Expand All @@ -61,8 +61,11 @@ Now that the interaction data has been loaded, the `CollisionData` instance to s
has been instantiated, the 3-dimensional array of `CollisionFactors` has been created, and the ``(\sigma g w)_{max}``
values precomputed, one can perform collisions.

Single-species elastic VHS collisions can be performed by calling
`ntc!(rng, collision_factors, collision_data, interaction, particles, pia, cell, species, Δt, V)`.
Single-species elastic VHS collisions for fixed-weight particles can be performed by calling
[`ntc_equal_weight!`](@ref).
A more generic function [`ntc!`](@ref)
is available, which checks whether particles have equal or non-equal weights (see [Variable-weight DSMC simulations](@ref)); for
purely equal-weight simulations it is however somewhat slower, thus it is recommended to use [`ntc_equal_weight!`](@ref).
Here `collision_factors` is the specific instance of `CollisionFactors`, i.e. a specific element of the
3-dimensional array of `CollisionFactors`. `Δt` is the timestep, and `V` is the volume of the physical cell
(for spatially homogeneous simulations this can be set to 1.0).
Expand Down Expand Up @@ -145,11 +148,11 @@ for ts in 1:n_t # loop over time
for s1 in s2:n_species # loop over second species
if (s1 == s2)
# collisions between particles of same species
ntc!(rng, collision_factors[s1,s1,1], collision_data,
ntc_equal_weight!(rng, collision_factors[s1,s1,1], collision_data,
interaction_data, particles[s1], pia, 1, s1, Δt, V)
else
# collisions between particles of different species
ntc!(rng, collision_factors[s1,s2,1], collision_data,
ntc_equal_weight!(rng, collision_factors[s1,s2,1], collision_data,
interaction_data, particles[s1], particles[s2],
pia, 1, s1, s2, Δt, V)
end
Expand Down
10 changes: 7 additions & 3 deletions docs/src/overview_varweight.md
Original file line number Diff line number Diff line change
Expand Up @@ -71,10 +71,14 @@ pia = ParticleIndexerArray(n_sampled)
```

## Colliding variable-weight particles
As mentioned above, the existing DSMC routines take care of the required particle splitting, so no specific adaptation is required
for the variable-weight case. However, one needs to estimate ``(\sigma g w)_{max}``. The simplest approach is to
As mentioned above, the existing DSMC routines, unless they have `equal_weight` explicitly in their name,
take care of the required particle splitting. For variable-weight NTC simulations, one needs to estimate ``(\sigma g w)_{max}``.
The simplest approach is to
use `estimate_sigma_g_w_max` function, but it requires a (fixed) value of `Fnum` - so one can simply compute it as
`ndens/n_sampled` (i.e. the number density divided by the total number of sampled particles).
`ndens/n_sampled` (i.e. the number density divided by the total number of sampled particles). If we merge after sampling,
an effective `Fnum` is then computed as `ndens/n_post_merge` (i.e. number density divided by the total number of post-merge particles).
The [`ntc!`](@ref) function has a keyword parameter `dw_tol` that governs when particle collisions are treated as equal-weight so that small
discrepancies in particle weights do not cause unnecessary splitting.

## Merging variable-weight particles
In order to merge variable-weight particles, one needs to set up a merging algorithm and the associated
Expand Down
3 changes: 3 additions & 0 deletions docs/src/reference_internal.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,8 @@ Merzbild.sample_maxwellian!
```@docs
Merzbild.compute_n_coll_single_species
Merzbild.compute_n_coll_two_species
Merzbild.collide_2particles_vhs!
Merzbild.collide_2particles_vhs_equal_weight!
Merzbild.compute_vhs_factor
Merzbild.compute_com!
Merzbild.compute_g!
Expand Down Expand Up @@ -149,6 +151,7 @@ Merzbild.AbstractNCDataHolder

## Parallel computations
```@docs
Merzbild.swap_particles_true_index!
Merzbild.swap_particles!
Merzbild.update_swap_indexing!
Merzbild.push_particles!
Expand Down
2 changes: 2 additions & 0 deletions docs/src/reference_public.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ ParticleIndexerArray(n_particles::Integer)
ParticleIndexerArray(n_particles::T) where T<:AbstractVector
ParticleIndexerArray(grid, species_data::Array{Species})
squash_pia!
restore_particle_ordering!
count_disordered_particles
check_unique_index
check_pia_is_correct
Expand Down Expand Up @@ -97,6 +98,7 @@ estimate_sigma_g_w_max!
estimate_sigma_g_w_max_ntc_n_e!
estimate_sigma_g_max!
ntc!
ntc_equal_weight!
ntc_n_e!
ntc_n_e_es!
swpm!
Expand Down
2 changes: 1 addition & 1 deletion scripts/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,4 +32,4 @@ python scripts/plot_1D.py --file scratch/data/couette_0.0005_50_500.0_300.0_1000
```

## Paper reproducibility scripts
Scripts to post-process simulation results for various papers can be found in the `reproducibility` subdirectory.
Scripts to post-process simulation results for various papers can be found in the `reproducibility` subdirectory.
3 changes: 1 addition & 2 deletions simulations/0D/BKW/bkw.jl
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
# 20k particles, julia --project=. simulations/basic/bkw.jl 4.73s user 1.75s system 133% cpu 4.874 total
# 50k particles, no print julia --project=. simulations/basic/bkw.jl 5.54s user 1.65s system 134% cpu 5.357 total
# 200k particles, 10 moments, no print julia --project=. simulations/basic/bkw.jl 13.29s user 1.78s system 114% cpu 13.211 total

using Merzbild
using Random

Expand Down Expand Up @@ -77,7 +76,7 @@ function run(seed)
V::Float64 = 1.0

@time for ts in 1:n_t
ntc!(rng, collision_factors, collision_data, interaction_data, particles[1],
ntc_equal_weight!(rng, collision_factors, collision_data, interaction_data, particles[1],
pia, 1, 1, Δt, V)

compute_props!(particles, pia, species_data, phys_props)
Expand Down
4 changes: 2 additions & 2 deletions simulations/0D/basic/basic_collisions_multispecies.jl
Original file line number Diff line number Diff line change
Expand Up @@ -60,9 +60,9 @@ function run(seed)
for s2 in 1:n_species
for s1 in s2:n_species
if (s1 == s2)
ntc!(rng, collision_factors[s1,s1,1], collision_data, interaction_data, particles[s1], pia, 1, s1, Δt, V)
ntc_equal_weight!(rng, collision_factors[s1,s1,1], collision_data, interaction_data, particles[s1], pia, 1, s1, Δt, V)
else
ntc!(rng, collision_factors[s1,s2,1], collision_data, interaction_data, particles[s1], particles[s2],
ntc_equal_weight!(rng, collision_factors[s1,s2,1], collision_data, interaction_data, particles[s1], particles[s2],
pia, 1, s1, s2, Δt, V)
end
end
Expand Down
8 changes: 7 additions & 1 deletion simulations/1D/couette_benchmarking.jl
Original file line number Diff line number Diff line change
Expand Up @@ -53,14 +53,16 @@ function run(seed, T_wall, v_wall, L, ndens, nx, ppc, Δt, n_timesteps, avg_star

n_avg = n_timesteps - avg_start + 1

index_inv_map = zeros(Int64, n_particles)

for t in 1:n_timesteps
if t % 1000 == 0
println(t)
end

# collide particles
for cell in 1:grid.n_cells
@timeit "collide" @inbounds ntc!(rng, collision_factors[1, 1, cell],
@timeit "collide" @inbounds ntc_equal_weight!(rng, collision_factors[1, 1, cell],
collision_data, interaction_data, particles[1], pia, cell, 1, Δt, grid.cells[cell].V)
end

Expand All @@ -72,6 +74,10 @@ function run(seed, T_wall, v_wall, L, ndens, nx, ppc, Δt, n_timesteps, avg_star

# compute props and do I/O

if t%10 == 0
@timeit "restore ordering" restore_particle_ordering!(particles[1], index_inv_map)
end

if (t >= avg_start)
@timeit "props compute" compute_props_sorted!(particles, pia, species_data, phys_props)
@timeit "avg physprops" avg_props!(phys_props_avg, phys_props, n_avg)
Expand Down
6 changes: 6 additions & 0 deletions simulations/1D/couette_fp.jl
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,8 @@ function run(seed, T_wall, v_wall, L, ndens, nx, ppc, Δt, output_freq, n_timest
write_grid("scratch/data/couette_$(L)_$(nx)_grid.nc", grid)

n_avg = n_timesteps - avg_start + 1

index_inv_map = zeros(Int64, n_particles)

for t in 1:n_timesteps
if t % 1000 == 0
Expand All @@ -71,6 +73,10 @@ function run(seed, T_wall, v_wall, L, ndens, nx, ppc, Δt, output_freq, n_timest
# sort particles
@timeit "sort" sort_particles!(gridsorter, grid, particles[1], pia, 1)

if t%10 == 0
@timeit "restore ordering" restore_particle_ordering!(particles[1], index_inv_map)
end

# compute props and do I/O

if (t < avg_start)
Expand Down
6 changes: 6 additions & 0 deletions simulations/1D/couette_fp_vw.jl
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,8 @@ function run(seed, T_wall, v_wall, L, ndens, nx, ppc, merge_threshold, merge_tar

n_avg = n_timesteps - avg_start + 1

index_inv_map = zeros(Int64, n_particles)

for t in 1:n_timesteps
if t % 1000 == 0
println(t)
Expand All @@ -92,6 +94,10 @@ function run(seed, T_wall, v_wall, L, ndens, nx, ppc, merge_threshold, merge_tar
# sort particles
@timeit "sort" sort_particles!(gridsorter, grid, particles[1], pia, 1)

if t%10 == 0
@timeit "restore ordering" restore_particle_ordering!(particles[1], index_inv_map)
end

# compute props and do I/O

if (t < avg_start)
Expand Down
5 changes: 5 additions & 0 deletions simulations/1D/couette_varweight_nnls.jl
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,8 @@ function run(seed, T_wall, v_wall, L, ndens, nx, ppc_sampled, merge_threshold, m

n_avg = n_timesteps - avg_start + 1

index_inv_map = zeros(Int64, n_particles)

for t in 1:n_timesteps
if t % 1000 == 0
println("$t, # of particles=$(pia.n_total[1])")
Expand Down Expand Up @@ -152,6 +154,9 @@ function run(seed, T_wall, v_wall, L, ndens, nx, ppc_sampled, merge_threshold, m
# sort particles
@timeit "sort" sort_particles!(gridsorter, grid, particles[1], pia, 1)

if t%10 == 0
@timeit "restore ordering" restore_particle_ordering!(particles[1], index_inv_map)
end

# compute props and do I/O
if (t < avg_start)
Expand Down
10 changes: 9 additions & 1 deletion simulations/1D/couette_varweight_octree.jl
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,10 @@ function run(seed, T_wall, v_wall, L, ndens, nx, ppc_sampled, merge_threshold, m

n_avg = n_timesteps - avg_start + 1

index_inv_map = zeros(Int64, n_particles)

index_inv_map = zeros(Int64, n_particles)

for t in 1:n_timesteps
if t % 1000 == 0
println(t)
Expand Down Expand Up @@ -107,7 +111,11 @@ function run(seed, T_wall, v_wall, L, ndens, nx, ppc_sampled, merge_threshold, m

# count % of particles where indexing is disordered
if t % 1000 == 0
println(count_disordered_particles(particles[1], pia, 1) / pia.n_total[1] * 100.0)
@timeit "disordered count" println(count_disordered_particles(particles[1], pia, 1) / pia.n_total[1] * 100.0)
end

if t%10 == 0
@timeit "restore ordering" restore_particle_ordering!(particles[1], index_inv_map)
end

# compute props and do I/O
Expand Down
6 changes: 6 additions & 0 deletions simulations/1D/couette_varweight_octree_swpm.jl
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,8 @@ function run(seed, T_wall, v_wall, L, ndens, nx, ppc_sampled, merge_threshold, m

n_avg = n_timesteps - avg_start + 1

index_inv_map = zeros(Int64, n_particles)

for t in 1:n_timesteps
if t % 1000 == 0
println(t)
Expand Down Expand Up @@ -108,6 +110,10 @@ function run(seed, T_wall, v_wall, L, ndens, nx, ppc_sampled, merge_threshold, m
println(count_disordered_particles(particles[1], pia, 1) / pia.n_total[1] * 100.0)
end

if t%10 == 0
@timeit "restore ordering" restore_particle_ordering!(particles[1], index_inv_map)
end

# compute props and do I/O
if (t < avg_start)
if (t % output_freq == 0)
Expand Down
6 changes: 6 additions & 0 deletions simulations/1D/couette_with_surface_quantities.jl
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,8 @@ function run(seed, T_wall, v_wall, L, ndens, nx, ppc, Δt, output_freq, n_timest
write_netcdf(ds, phys_props, 0)
write_grid("scratch/data/couette_$(L)_$(nx)_grid.nc", grid)

index_inv_map = zeros(Int64, n_particles)

n_avg = n_timesteps - avg_start + 1

for t in 1:n_timesteps
Expand Down Expand Up @@ -98,6 +100,10 @@ function run(seed, T_wall, v_wall, L, ndens, nx, ppc, Δt, output_freq, n_timest
end
end

if t%10 == 0
@timeit "restore ordering" restore_particle_ordering!(particles[1], index_inv_map)
end

# compute props and do I/O

if (t < avg_start)
Expand Down
Loading
Loading