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

Develop #736

Merged
merged 29 commits into from
Aug 15, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
a8dda50
proper initialization of Dnom_tunnel
beck-llr Jun 27, 2024
08985b0
Fix bug for species specific diagnostics with AM vecto
beck-llr Jun 27, 2024
922cc85
fix diag custom functions with python 3.12
Jun 28, 2024
049f169
Handle AM prescribed fields as Cartesian ones
beck-llr Jun 28, 2024
e108d24
Small doc improvement on external and prescribed fields
beck-llr Jun 28, 2024
78c57bf
fix python changes for tornado
Jun 28, 2024
20c472e
Handle species reflective boundary conditions on Rmax in AM.
beck-llr Jul 1, 2024
4ba471a
fix happi average (last bin)
Jul 2, 2024
4aaef8b
clarification on the Prescribed Fields in the doc
Jul 5, 2024
9b42649
move initExchParticles outside of dynamics
Jul 11, 2024
42d097b
remove useless test in exch particles
Jul 11, 2024
da16dc0
New am shape functions
beck-llr Jul 12, 2024
0f98f09
Merge branch 'newAM_shape_functions' into 'develop'
beck-llr Jul 12, 2024
fb430ac
Update release status
beck-llr Jul 12, 2024
41e8dfa
fix again threading with python
Jul 16, 2024
4f4fc13
Merge branch 'develop' of llrgit.in2p3.fr:smilei/smilei into develop
Jul 16, 2024
e633efe
Correct buffer intialization for Ruyten Projector
beck-llr Jul 17, 2024
20e17af
Merge branch 'develop' of llrgit.in2p3.fr:smilei/smilei into develop
beck-llr Jul 17, 2024
53c761b
Typo in Ruyten interpolator
beck-llr Jul 17, 2024
de50a84
add warnings for the envelope
Jul 19, 2024
af4ee6d
message to say that the B-TIS3 is activated
Jul 19, 2024
eb16a04
Updated the doc on GPU support
charlesprouveur Jul 21, 2024
387b3b4
Removed useless declaration in 1D GPU projector that triggered unused…
charlesprouveur Jul 22, 2024
9d445cd
fix weight units for openPMD
Jul 25, 2024
27f316f
typo in previous commit
Jul 25, 2024
c95a9be
fixed necessary override in projector 1D order 2 for GPU
charlesprouveur Jul 26, 2024
f2b7bf1
fix for 1D GPU with no diag every iteration
charlesprouveur Aug 8, 2024
3e775f0
removed useless class member pointers Jx_, etc. in 1D, could be don…
charlesprouveur Aug 8, 2024
20231e3
update releases.rst
Aug 15, 2024
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
98 changes: 98 additions & 0 deletions benchmarks/tstAM_04d_laser_propagation_Order1.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,98 @@
# ----------------------------------------------------------------------------------------
# SIMULATION PARAMETERS FOR THE PIC-CODE SMILEI
# ----------------------------------------------------------------------------------------

import math
dx = 0.251327
dtrans = 1.96349
dt = 0.96 * dx
nx = 960
ntrans = 256
Lx = nx * dx
Ltrans = ntrans * dtrans
npatch_x = 64
npatch_trans =32
Nit = 2000


Main(
geometry = "AMcylindrical",
number_of_AM=2,
interpolation_order = 1,
timestep = dt,
simulation_time = dt*Nit,
cell_length = [dx, dtrans],
grid_length = [ Lx, Ltrans],
number_of_patches = [npatch_x, npatch_trans],
cluster_width = 5,
EM_boundary_conditions = [
["silver-muller","silver-muller"],
["PML","PML"],
],
number_of_pml_cells = [[0,0], [10,10]],
solve_poisson = False,
print_every = 100
)

MovingWindow(
time_start = Main.grid_length[0] - 50*dx, #Leaves 2 patches untouched, in front of the laser.
velocity_x = 0.996995486
)

ne = 0.0045
begin_upramp = 10. #Density is 0 before that and up ramp starts.
Lupramp = 100. #Length of the upramp
Lplateau = 15707. #Length of the plateau
Ldownramp = 2356.19 #Length of the down ramp
xplateau = begin_upramp + Lupramp # Start of the plateau
begin_downramp = xplateau + Lplateau # Beginning of the output ramp.
finish = begin_downramp + Ldownramp # End of plasma

g = polygonal(xpoints=[begin_upramp, xplateau, begin_downramp, finish], xvalues=[0, ne, ne, 0.])

def my_profile(x,y):
return g(x,y)

Species(
name = "electron",
position_initialization = "regular",
momentum_initialization = "cold",
ionization_model = "none",
particles_per_cell = 30,
c_part_max = 1.0,
mass = 1.0,
charge = -1.0,
charge_density = my_profile, # Here absolute value of the charge is 1 so charge_density = nb_density
mean_velocity = [0., 0., 0.],
time_frozen = 0.0,
boundary_conditions = [
["remove", "remove"],
["reflective", "remove"],
],
)

laser_fwhm = 82.
LaserGaussianAM(
box_side = "xmin",
a0 = 2.,
focus = [10.],
waist = 120.,
time_envelope = tgaussian(center=2**0.5*laser_fwhm, fwhm=laser_fwhm)
)

DiagProbe(
every = 1000,
origin = [0., 2*dtrans, 0.],
corners = [
[Main.grid_length[0], 2*dtrans, 0.]
],
number = [nx],
)

DiagPerformances(
every = 1000,
)

DiagScalar(
every = 20
)
24 changes: 19 additions & 5 deletions doc/Sphinx/Overview/releases.rst
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,27 @@ Get Smilei

You can find older, `unsupported versions here <https://github.com/SmileiPIC/Smilei/releases>`_

..
.. ----
----

.. _latestVersion:

Changes made in the repository (not released)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

* **Features**:

* Prescribed fields in AM geometry.
* Particle reflective boundary conditions at Rmax in AM geometry.
* 1st order Ruyten shape function in AM geometry.

* **Bug fixes**:

.. .. _latestVersion:
* Tunnel ionization was wrong in some cases for high atomic numbers.
* Custom functions in ``ParticleBinning`` crashed with python 3.12.
* Species-specific diagnostics in AM geometry with vectorization.
* Happi's ``average`` argument would sometimes be missing the last bin.
* 1D projector on GPU without diagnostics

.. Changes made in the repository (not released)
.. ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

----

Expand Down
8 changes: 5 additions & 3 deletions doc/Sphinx/Understand/GPU_offloading.rst
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,11 @@ the announced exaflopic supercomputers will include GPUs.
* Currently supported features:

* Both AMD's GPUs and Nvidia's GPUs are supported
* Cartesian geometry in 2D and in 3D
* Cartesian geometry in 1D, 2D and in 3D , for order 2
* Diagnostics: Field, Probes, Scalar, ParticleBinning, TrackParticles
* Moving Window.
* Moving Window

* A few key features remain to be implemented (AM geometry, ionization, PML, envelope,
additional physics), but the fundamentals of the code are ported.
additional physics), but the fundamentals of the code are ported.

* Short term roadmap We are currently working on porting on GPU the following features: AM geometry (order 2) and collisions
23 changes: 23 additions & 0 deletions doc/Sphinx/Use/GPU_version.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
GPU version of SMILEI
-------


This page contains the links of this documentation to compile and run SMILEI on GPU clusters, as well as the list of the features that are supported or in development

* :doc:`Introduction</Overview/highlights>` #Improved performance using GPU offloading

* :doc:`GPU offloading , supported features, guidelines and roadmap</Understand/GPU_offloading>`

* :doc:`Intallation and compilation</Use/install_linux_GPU>`

* :doc:`Compilation for GPU-accelerated nodes</Use/installation>` #compilation-for-gpu-accelerated-nodes

* :doc:`Running on GPU-equiped nodes</Use/run>` #running-on-gpu-equiped-nodes

----

Known issues
^^^^^^^^^^^^

2D and 3D runs may crash with A2000 & A6000 GPUs (used in laptops and worstations respectively,
they are not 'production GPUs' which are designed for 64 bits floating point operations )
2 changes: 0 additions & 2 deletions doc/Sphinx/Use/installation.rst
Original file line number Diff line number Diff line change
Expand Up @@ -185,8 +185,6 @@ Typically ``CXXFLAGS += -ta=tesla:cc80`` for ``nvhpc`` <23.4 and

.. warning::

* We are aware of issues with CUDA >12.0, fixes are being tested but are not deployed yet.
We recommend CUDA 11.x at the moment.
* The hdf5 module should be compiled with the nvidia/cray compiler;
openmpi as well, but depending on the nvhpc module it might not be needed as it can be included in the nvhpc module.

Expand Down
24 changes: 20 additions & 4 deletions doc/Sphinx/Use/namelist.rst
Original file line number Diff line number Diff line change
Expand Up @@ -143,9 +143,13 @@ The block ``Main`` is **mandatory** and has the following syntax::

Interpolation order, defines particle shape function:

* ``1`` : 2 points stencil in r with Ruyten correction, 3 points stencil in x. Supported only in AM geometry.
* ``2`` : 3 points stencil, supported in all configurations.
* ``4`` : 5 points stencil, not supported in vectorized 2D geometry.

The Ruyten correction is the scheme described bu equation 4.2 in `this paper <https://www.sciencedirect.com/science/article/abs/pii/S0021999183710703>`_ .
It allows for a more accurate description on axis at the cost of a higher statistic noise so it often requires the use of more macro-particles.

.. py:data:: interpolator

:default: ``"momentum-conserving"``
Expand Down Expand Up @@ -2009,8 +2013,8 @@ at the beginning of the simulation using the ``ExternalField`` block::

.. py:data:: field

Field name in Cartesian geometries: ``"Ex"``, ``"Ey"``, ``"Ez"``, ``"Bx"``, ``"By"``, ``"Bz"``, ``"Bx_m"``, ``"By_m"``, ``"Bz_m"``
Field name in AM geometry: ``"El"``, ``"Er"``, ``"Et"``, ``"Bl"``, ``"Br"``, ``"Bt"``, ``"Bl_m"``, ``"Br_m"``, ``"Bt_m"``, ``"A"``, ``"A0"`` .
Field names in Cartesian geometries: ``"Ex"``, ``"Ey"``, ``"Ez"``, ``"Bx"``, ``"By"``, ``"Bz"``, ``"Bx_m"``, ``"By_m"``, ``"Bz_m"``.
Field names in AM geometry: ``"El_mode_m"``, ``"Er_mode_m"``, ``"Et_mode_m"``, ``"Bl_mode_m"``, ``"Br_mode_m"``, ``"Bt_mode_m"``, ``"Bl_m_mode_m"``, ``"Br_m_mode_m"``, ``"Bt_m_mode_m"``, ``"A_mode_1"``, ``"A0_mode_1"`` .

.. py:data:: profile

Expand Down Expand Up @@ -2055,13 +2059,25 @@ This feature is accessible using the ``PrescribedField`` block::

.. py:data:: field

Field name: ``"Ex"``, ``"Ey"``, ``"Ez"``, ``"Bx_m"``, ``"By_m"`` or ``"Bz_m"``.
Field names in Cartesian geometries: ``"Ex"``, ``"Ey"``, ``"Ez"``, ``"Bx_m"``, ``"By_m"`` or ``"Bz_m"``.
Field names in AM geometry: ``"El_mode_m"``, ``"Er_mode_m"``, ``"Et_mode_m"``, ``"Bl_m_mode_m"``, ``"Br_m_mode_m"`` or ``"Bt_m_mode_m"``.

.. warning::

When prescribing a magnetic field, always use the time-centered fields ``"Bx_m"``, ``"By_m"`` or ``"Bz_m"``.
These fields are those used in the particle pusher, and are defined at integer time-steps.

.. warning::

When prescribing a field in AM geometry, the mode "m" must be specified explicitly in the name of the field and the profile
must return a complex value.

.. warning::

``PrescribedFields`` are not visible in the ``Field`` diagnostic,
but can be visualised through ``Probes`` and with the fields attributes of ``TrackParticles``
(since they sample the total field acting on the macro-particles).

.. py:data:: profile

:type: float or :doc:`profile <profiles>`
Expand Down Expand Up @@ -3641,4 +3657,4 @@ namelist. They should not be re-defined by the user!
.. note::

These variables can be access during ``happi`` post-processing, e.g.
``S.namelist.smilei_mpi_size``.
``S.namelist.smilei_mpi_size``.
1 change: 1 addition & 0 deletions doc/Sphinx/use.rst
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,4 @@ Use
Use/post-processing
Use/contribute
Use/troubleshoot
Use/GPU_version
4 changes: 2 additions & 2 deletions happi/_Diagnostics/Diagnostic.py
Original file line number Diff line number Diff line change
Expand Up @@ -578,8 +578,8 @@ def _selectRange(self, portion, meshpoints, axisname, axisunits, operation, edge
info = operation+" for "+axisname+" from "+axismin+" to "+axismax
else:
info = operation+" for "+axisname+" from "+str(meshpoints[indices[0]])+" to "+str(meshpoints[indices[-1]])+" "+axisunits
selection = slice(indices[0],indices[-1])
finalShape = indices[-1] - indices[0]
selection = slice(indices[0], indices[-1] + 1)
finalShape = indices[-1] - indices[0] + 1
return info, selection, finalShape

# Method to prepare some data before plotting
Expand Down
4 changes: 2 additions & 2 deletions src/Diagnostic/DiagnosticNewParticles.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -93,8 +93,8 @@ void DiagnosticNewParticles::openFile( Params &params, SmileiMPI *smpi )
}
}
if( write_weight_ ) {
loc_weight_ = newDataset( species_group, "weight", H5T_NATIVE_DOUBLE, file_space, SMILEI_UNIT_DENSITY );
openPMD_->writeRecordAttributes( *loc_weight_, SMILEI_UNIT_DENSITY );
loc_weight_ = newDataset( species_group, "weight", H5T_NATIVE_DOUBLE, file_space, SMILEI_UNIT_WEIGHT );
openPMD_->writeRecordAttributes( *loc_weight_, SMILEI_UNIT_WEIGHT );
}
if( write_chi_ ) {
loc_chi_ = newDataset( species_group, "chi", H5T_NATIVE_DOUBLE, file_space, SMILEI_UNIT_NONE );
Expand Down
2 changes: 1 addition & 1 deletion src/Diagnostic/DiagnosticParticleList.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -299,7 +299,7 @@ void DiagnosticParticleList::run( SmileiMPI *smpi, VectorPatch &vecPatches, int
if( write_weight_ ) {
fill_buffer( vecPatches, iprop, data_double );
#pragma omp master
write_scalar_double( loc_weight_, "weight", data_double[0], file_space, mem_space, SMILEI_UNIT_DENSITY );
write_scalar_double( loc_weight_, "weight", data_double[0], file_space, mem_space, SMILEI_UNIT_WEIGHT );
}

iprop++;
Expand Down
64 changes: 31 additions & 33 deletions src/Diagnostic/Histogram.h
Original file line number Diff line number Diff line change
Expand Up @@ -578,25 +578,24 @@ class HistogramAxis_user_function : public HistogramAxis
private:
void calculate_locations( Species *s, double *array, int *index, unsigned int npart, SimWindow * )
{
#pragma omp critical
SMILEI_PY_ACQUIRE_GIL
// Expose particle data as numpy arrays
particleData.resize( npart );
particleData.set( s->particles );
// run the function
PyArrayObject *ret = ( PyArrayObject * )PyObject_CallFunctionObjArgs( function, particleData.get(), NULL );
particleData.clear();
// Copy the result to "array"
double *arr = ( double * ) PyArray_GETPTR1( ret, 0 );
for( unsigned int ipart = 0 ; ipart < npart ; ipart++ )
{
// Expose particle data as numpy arrays
particleData.resize( npart );
particleData.set( s->particles );
// run the function
PyArrayObject *ret = ( PyArrayObject * )PyObject_CallFunctionObjArgs( function, particleData.get(), NULL );
particleData.clear();
// Copy the result to "array"
double *arr = ( double * ) PyArray_GETPTR1( ret, 0 );
for( unsigned int ipart = 0 ; ipart < npart ; ipart++ )
{
if( index[ipart]<0 ) {
continue;
}
array[ipart] = arr[ipart];
if( index[ipart]<0 ) {
continue;
}
Py_DECREF( ret );
array[ipart] = arr[ipart];
}
Py_DECREF( ret );
SMILEI_PY_RELEASE_GIL
};

PyObject *function;
Expand Down Expand Up @@ -1167,26 +1166,25 @@ class Histogram_user_function : public Histogram
void valuate( Species *s, double *array, int *index )
{
unsigned int npart = s->getNbrOfParticles();
#pragma omp critical
{
// Expose particle data as numpy arrays
particleData.resize( npart );
particleData.set( s->particles );
// run the function
PyArrayObject *ret = ( PyArrayObject * )PyObject_CallFunctionObjArgs( function, particleData.get(), NULL );
particleData.clear();
// Copy the result to "array"
double *arr = ( double * ) PyArray_GETPTR1( ret, 0 );
for( unsigned int ipart = 0 ; ipart < npart ; ipart++ ) {
if( index[ipart]<0 ) {
continue;
}
array[ipart] = arr[ipart];
SMILEI_PY_ACQUIRE_GIL
// Expose particle data as numpy arrays
particleData.resize( npart );
particleData.set( s->particles );
// run the function
PyArrayObject *ret = ( PyArrayObject * )PyObject_CallFunctionObjArgs( function, particleData.get(), NULL );
particleData.clear();
// Copy the result to "array"
double *arr = ( double * ) PyArray_GETPTR1( ret, 0 );
for( unsigned int ipart = 0 ; ipart < npart ; ipart++ ) {
if( index[ipart]<0 ) {
continue;
}
Py_DECREF( ret );
array[ipart] = arr[ipart];
}
Py_DECREF( ret );
SMILEI_PY_RELEASE_GIL
};

PyObject *function;
ParticleData particleData;
};
Expand Down
Loading
Loading