New option for initial distribution of species

The number of particles per cell can be defined when giving an initial
distribution fora species. If not, the typical method of using the
species weight is used. This is particularly useful for cylindrical
coordinates in which very little particles might end up in the axis if a
constant weight is used.
This commit is contained in:
Jorge Gonzalez 2024-07-07 14:37:34 +02:00
commit 1f2ec8d82f
4 changed files with 97 additions and 8 deletions

View file

@ -0,0 +1,77 @@
% Encoding: UTF-8
@InProceedings{boris1970relativistic,
author = {Boris, Jay P},
booktitle = {Proc. Fourth Conf. Num. Sim. Plasmas},
title = {Relativistic plasma simulation-optimization of a hybrid code},
year = {1970},
pages = {3--67},
}
@article{higginson2020corrected,
title={A corrected method for Coulomb scattering in arbitrarily weighted particle-in-cell plasma simulations},
author={Higginson, Drew Pitney and Holod, Ihor and Link, Anthony},
journal={Journal of Computational Physics},
volume={413},
pages={109450},
year={2020},
publisher={Elsevier}
}
@Misc{gfortranURL,
author = {GNU Project},
title = {gfortran - the GNU Fortran compiler},
howpublished = {\url{https://gcc.gnu.org/wiki/GFortran}},
}
@Misc{ifortURL,
author = {Intel\textsuperscript{\textregistered}},
title = {Intel\textsuperscript{\textregistered} Fortran Compiler},
howpublished = {\url{https://software.intel.com/content/www/us/en/develop/tools/oneapi/components/fortran-compiler.html}},
}
@Misc{openblasURL,
title = {OpenBLAS, an optimized BLAS library},
howpublished = {\url{https://www.openblas.net/}},
}
@Misc{jsonfortranURL,
title = {JSON-Fortran},
howpublished = {\url{https://github.com/jacobwilliams/json-fortran}},
}
@Misc{jsonURL,
title = {JSON, JavaScript Object Notation},
howpublished = {\url{https://www.json.org/json-en.html}},
}
@Misc{gmshURL,
author = {Christophe Geuzaine and Jean-François Remacle},
title = {Gmsh},
howpublished = {\url{https://gmsh.info/}},
}
@Article{welford1962note,
author = {Welford, BP},
journal = {Technometrics},
title = {Note on a method for calculating corrected sums of squares and products},
year = {1962},
number = {3},
pages = {419--420},
volume = {4},
publisher = {Taylor \& Francis},
}
@Article{sherlock2008monte,
author = {Sherlock, Mark},
journal = {Journal of Computational Physics},
title = {A Monte-Carlo method for Coulomb collisions in hybrid plasma models},
year = {2008},
number = {4},
pages = {2286--2292},
volume = {227},
groups = {Particle-in-cell},
publisher = {Elsevier},
}
@Comment{jabref-meta: databaseType:bibtex;}

Binary file not shown.

View file

@ -713,6 +713,10 @@ make
The file format must be the same as in \textbf{geometry.meshType} The file format must be the same as in \textbf{geometry.meshType}
Initial particles are assumed to have a Maxwellian distribution. Initial particles are assumed to have a Maxwellian distribution.
File must be located at \textbf{output.path}. File must be located at \textbf{output.path}.
\item \textbf{particlesPerCell}: Integer.
Optional.
Initial number of particles per cell.
If not, the number of particles per cell will be assigned based on the species weight and the cell volume.
\end{itemize} \end{itemize}
\end{itemize} \end{itemize}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

View file

@ -324,7 +324,8 @@ MODULE moduleInput
REAL(8):: densityCen REAL(8):: densityCen
!Mean velocity and temperature at particle position !Mean velocity and temperature at particle position
REAL(8):: velocityXi(1:3), temperatureXi REAL(8):: velocityXi(1:3), temperatureXi
INTEGER:: nNewPart = 0.D0 INTEGER:: nNewPart = 0
REAL(8):: weight = 0.D0
CLASS(meshCell), POINTER:: cell CLASS(meshCell), POINTER:: cell
TYPE(particle), POINTER:: partNew TYPE(particle), POINTER:: partNew
REAL(8):: vTh REAL(8):: vTh
@ -343,6 +344,9 @@ MODULE moduleInput
!Reads node values at the nodes !Reads node values at the nodes
filename = path // spFile filename = path // spFile
CALL mesh%readInitial(filename, density, velocity, temperature) CALL mesh%readInitial(filename, density, velocity, temperature)
!Check if initial number of particles is given
CALL config%get(object // '.particlesPerCell', nNewPart, found)
!For each volume in the node, create corresponding particles !For each volume in the node, create corresponding particles
DO e = 1, mesh%numCells DO e = 1, mesh%numCells
!Scale variables !Scale variables
@ -355,7 +359,11 @@ MODULE moduleInput
densityCen = mesh%cells(e)%obj%gatherF((/ 0.D0, 0.D0, 0.D0 /), nNodes, sourceScalar) densityCen = mesh%cells(e)%obj%gatherF((/ 0.D0, 0.D0, 0.D0 /), nNodes, sourceScalar)
!Calculate number of particles !Calculate number of particles
nNewPart = INT(densityCen * (mesh%cells(e)%obj%volume*Vol_ref) / species(sp)%obj%weight) IF (.NOT. found) THEN
nNewPart = FLOOR(densityCen * (mesh%cells(e)%obj%volume*Vol_ref) / species(sp)%obj%weight)
END IF
weight = densityCen * (mesh%cells(e)%obj%volume*Vol_ref) / REAL(nNewPart)
!Allocate new particles !Allocate new particles
DO p = 1, nNewPart DO p = 1, nNewPart
@ -392,7 +400,7 @@ MODULE moduleInput
partNew%n_in = .TRUE. partNew%n_in = .TRUE.
partNew%weight = species(sp)%obj%weight partNew%weight = weight
!Assign particle to temporal list of particles !Assign particle to temporal list of particles
CALL partInitial%add(partNew) CALL partInitial%add(partNew)