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

Segmentation fault (core dumped) on running for D-D fusion simulation #615

Closed
xiaowang119 opened this issue Apr 7, 2023 · 22 comments
Closed
Labels

Comments

@xiaowang119
Copy link

Description

Hi, friends! Some error occur when I use SMILEI for D-D fusion. Code will be Interrupted with "Segmentation fault (core dumped)" for some cell number(eg. resx=resy=128), but run well for others(eg. resx=resy=64). And it also run well while I removed the fusion section. Any suggestion for me? Thanks a lot!

[WARNING](0) src/Params/Params.cpp:1385 (print_timestep_headers) The following `push time` assumes a global nu
mber of 104 cores (hyperthreading is unknown)                                                                 
      timestep       sim time   cpu time [s]   (    diff [s] )   push time [ns]                               
    4022/40226     1.2566e+02     1.0048e+03   (  1.0048e+03 )            4920                                
    8044/40226     2.5130e+02     2.0287e+03   (  1.0239e+03 )            4961                                
   12066/40226     3.7695e+02     3.0853e+03   (  1.0566e+03 )            5051    
Stack trace (most recent call last) in thread 2180634:                                                        
#7    Object "[0xffffffffffffffff]", at 0xffffffffffffffff, in                                                
#6    Object "/lib/x86_64-linux-gnu/libc.so.6", at 0x7f567063b132, in clone                                   
#5    Object "/lib/x86_64-linux-gnu/libpthread.so.0", at 0x7f5670bd4608, in                                   
#4    Object "/usr/lib/x86_64-linux-gnu/libgomp.so.1", at 0x7f567074378d, in                                  
#3    Object "../build/smilei", at 0x5603fb36320d, in                                                         
#2    Object "../build/smilei", at 0x5603fb2b712f, in VectorPatch::dynamics(Params&, SmileiMPI*, SimWindow*, R
adiationTables&, MultiphotonBreitWheelerTables&, double, Timers&, int)                                        
#1    Object "../build/smilei", at 0x5603fb3762d5, in SpeciesV::dynamics(double, unsigned int, ElectroMagn*, P
arams&, bool, PartWalls*, Patch*, SmileiMPI*, RadiationTables&, MultiphotonBreitWheelerTables&, std::vector<Di
agnostic*, std::allocator<Diagnostic*> >&)                                                                    
#0    Object "../build/smilei", at 0x5603fb375896, in SpeciesV::computeParticleCellKeys(Params&, Particles*, i
nt*, int*, unsigned int, unsigned int)                                                                        
Segmentation fault (Address not mapped to object [0x5601fdb15110])                                            
Segmentation fault (core dumped)

Parameters

  • Smilei version 4.7
  • Computing resources
    • OS
      Distributor ID: Ubuntu
      Description: Ubuntu 20.04.5 LTS
      Release: 20.04
      Codename: focal
    • C++ compiler (to get some information g++ --version)
      g++ (Ubuntu 9.4.0-1ubuntu1~20.04.1) 9.4.0
    • MPI version (mpic++ --version, mpic++ -show)
      g++ (Ubuntu 9.4.0-1ubuntu1~20.04.1) 9.4.0
      g++ -I/usr/local/openmpi/include -pthread -Wl,-rpath -Wl,/usr/local/openmpi/lib -Wl,--enable-new-dtags -L/usr/local/openmpi/lib -lmpi
    • HDF5 version (h5cc --version)
      g++ (Ubuntu 9.4.0-1ubuntu1~20.04.1) 9.4.0
    • Python version (python --version)
      Python 3.8.10

Namelist and outlog are attached.

@xiaowang119 xiaowang119 added the bug label Apr 7, 2023
@xiaowang119
Copy link
Author

attachment

@xiaowang119
Copy link
Author

xiaowang119 commented Apr 7, 2023

The function of uploading attachment seems to get wrong. I will post text directly here.

namelist

# ----------------------------------------------------------------------------------------
# 					SIMULATION PARAMETERS FOR THE PIC-CODE SMILEI
# ----------------------------------------------------------------------------------------

import math

# Reference
l0 = 2.0 * math.pi  # laser wavelength 800nm/1um (2*pi*lr)
t0 = l0  # optical cicle 2.66851fs/3.333fs

# Simulation parameters for 800nu
# lm = l0 * 5.0 / 4.0  # 1um
# lr = 8e-7 / (2.0 * math.pi)  # show the value of unit of length in smilei as SI unit
# tm = 5.0 * math.pi / 2.0  # 3.33fs

# Simulation parameters for 1um
lm = l0  # 1um
lr = 1e-6 / (2.0 * math.pi)  # show the value of unit of length in smilei as SI unit
tm = t0  # 3.33fs


Lsim = [4.0 * lm, 2.0 * lm]  # length of the simulation  4um × 2um
# Lsim = [5.0 * lm, 15.0 * lm]
# Lcell = [0.01*l0, 0.01*l0]
resx = 128.0  # nb of cells in on a lm
resy = 128.0
Tsim = 200.0 * t0  # duration of the simulation for 10 laser wavelength (about 48 tm)
# rest = 60.              # time of timestep in one optical cycle

# Laser
omega = 1.0  # = 2PI/t0
a0 = 5.0  # 8.4 、10 、11.85

# particles in per cell
ppc = 16


def preprocess():
    # density = 22.2203  # density of Carbon atom on 800nm
    density = 34.6643  # density of Carbon atom on 1um
    if smilei_mpi_rank == 0:
        import numpy as np
        from numpy import linspace, meshgrid, ceil
        import h5py

        # 输出模拟尺寸 及 网格大小(用作delta)
        with open("Box.txt", "w") as f:
            f.write(f"{Lsim[0]} {Lsim[1]} {2.0*lm/resx}")

        vertices = [
            (0.2 * Lsim[0], 0.2 * Lsim[1]),  # (0.8 * Lsim[0], 0.1 * Lsim[1]),
            (0.2 * Lsim[0], 0.8 * Lsim[1]),  # (0.8 * Lsim[0], 0.9 * Lsim[1]),
            (0.8 * Lsim[0], 0.8 * Lsim[1]),  # (0.9 * Lsim[0], 0.9 * Lsim[1]),
            (0.8 * Lsim[0], 0.2 * Lsim[1]),  # (0.9 * Lsim[0], 0.1 * Lsim[1]),
        ]  # 多边形顶点数据
        with open("vertices.txt", "w") as f:
            for vertex in vertices:
                f.write(f"{vertex[0]} {vertex[1]}\n")

        vertices = np.loadtxt("vertices.txt")
        p = linspace(0.0, Lsim[0], int(resx * ceil(Lsim[0] / lm)) + 1)
        q = linspace(0.0, Lsim[1], int(resy * ceil(Lsim[1] / lm)) + 1)
        xx, yy = meshgrid(p, q)
        points = np.vstack((xx.ravel(), yy.ravel())).T

        def is_point_in_polygon(point, polygon):
            """
            判断一个点是否在多边形内部

            Args:
                    point: tuple, 待判断的点坐标
                    polygon: ndarray, 多边形的顶点坐标, 形状为(n, 2)

            Returns:
                    bool, True表示在多边形内部, False表示在外部
            """
            # 将多边形的顶点按顺时针排序
            x, y = polygon[:, 0], polygon[:, 1]
            cx, cy = x.mean(), y.mean()
            angles = np.arctan2(y - cy, x - cx)
            sorted_idx = np.argsort(angles)
            polygon = polygon[sorted_idx]

            # 计算射线与多边形的交点个数
            x, y = polygon[:, 0], polygon[:, 1]
            n = len(polygon)
            count = 0
            for i in range(n):
                x1, y1 = x[i], y[i]
                x2, y2 = x[(i + 1) % n], y[(i + 1) % n]
                if (point[0] == x1 and point[1] == y1) or (
                    point[0] == x2 and point[1] == y2
                ):
                    return True  # 点在多边形上
                if (y1 > point[1]) != (y2 > point[1]) and point[0] < x1 + (x2 - x1) * (
                    point[1] - y1
                ) / (y2 - y1):
                    count += 1
            return count % 2 == 1

        is_inside = np.array([is_point_in_polygon(p, vertices) for p in points])
        lenx = p.size
        leny = q.size
        data_C = np.zeros((lenx, leny))  # for Carbon atom
        data_D = np.zeros((lenx, leny))  # for Deuterium atom
        # data_E = np.zeros((lenx, leny))  # for Electron
        for j in range(leny):
            for i in range(lenx):
                data_C[i, j] = density if (is_inside[j * lenx + i]) else 0.0
                data_D[i, j] = density * 2.0 if (is_inside[j * lenx + i]) else 0.0
                # data_E[i, j] = density*8. if (is_inside[j*lenx+i]) else 0.0
        with h5py.File("CD2-profile.h5", "w") as f:
            g = f.create_group("density_group")
            g.create_dataset("C_profile", data=data_C)
            g.create_dataset("D_profile", data=data_D)
            # g.create_dataset("E_profile", data=data_E)


Main(
    geometry="2Dcartesian",
    interpolation_order=2,
    # reference_angular_frequency_SI=2*math.pi*3e8/1.e-6/0.8,  # Lr=0.8/2pi
    reference_angular_frequency_SI=3e8 / lr,  # ωr = c/lr
    grid_length=Lsim,
    cell_length=[lm / resx, lm / resx],  # [l0/resx, l0/resx],
    number_of_patches=[8, 8],
    # timestep=t0/rest,
    timestep_over_CFL=0.9,
    simulation_time=Tsim,
    EM_boundary_conditions=[
        ["silver-muller"],
        ["periodic"],
    ],
    # print_every = 1,
    cluster_width=1,
)


LaserPlanar1D(
    box_side="xmin",
    a0=a0,
    omega=omega,
    polarization_phi=0.0,
    ellipticity=0.0,
    # time_envelope=tconstant(),
    time_envelope=tgaussian(
        start=0.0, duration=33 * t0, fwhm=15.0 * t0, center=15.0 * t0
    ),
)


# Deuterium
Species(
    name="Deuterium",
    position_initialization="regular",
    momentum_initialization="mj",
    ionization_model="tunnel",
    ionization_electrons="Electron",
    temperature=[5.0e-8],
    particles_per_cell=ppc,
    # c_part_max=1.0,
    mass=3670.03,  # 3675.18,
    charge=0.0,
    atomic_number=1,
    number_density="CD2-profile.h5/density_group/D_profile",
    # mean_velocity=[0.5, 0., 0.],
    # time_frozen=0.0,
    boundary_conditions=[
        ["stop", "stop"],
        ["periodic", "periodic"],
    ],
)

# Carbon
Species(
    name="Carbon",
    position_initialization="regular",
    momentum_initialization="mj",
    ionization_model="tunnel",
    ionization_electrons="Electron",
    temperature=[5.0e-8],
    particles_per_cell=ppc,
    # c_part_max=1.0,
    mass=21866.04,
    charge=0.0,
    atomic_number=6,
    number_density="CD2-profile.h5/density_group/C_profile",
    # mean_velocity=[-0.5, 0., 0.],
    # time_frozen=0.0,
    boundary_conditions=[
        ["stop", "stop"],
        ["periodic", "periodic"],
    ],
)

# Helium-3
Species(
    name="He3",
    position_initialization="regular",
    momentum_initialization="cold",
    # ionization_model='tunnel',
    # ionization_electrons='Electron',
    # temperature=[5.0e-8],
    particles_per_cell=ppc,
    # c_part_max=1.0,
    mass=5495.66,
    charge=0.0,
    atomic_number=2,
    number_density=0.0,  # 'CD2-profile.h5/density_group/C_profile',
    # mean_velocity=[-0.5, 0., 0.],
    # time_frozen=0.0,
    boundary_conditions=[
        ["stop", "stop"],
        ["periodic", "periodic"],
    ],
)

# Neutron
Species(
    name="Neutron",
    position_initialization="regular",
    momentum_initialization="mj",
    temperature=[5.0e-8],
    particles_per_cell=ppc,
    # c_part_max=1.0,
    mass=1822.17,
    charge=0.0,
    atomic_number=0,
    number_density=0.0,  # 'CD2-profile.h5/density_group/C_profile',
    # mean_velocity=[-0.5, 0., 0.],
    # time_frozen=0.0,
    boundary_conditions=[
        ["stop", "stop"],
        ["periodic", "periodic"],
    ],
)

# Electron
Species(
    name="Electron",
    position_initialization="regular",
    momentum_initialization="mj",
    temperature=[5.0e-8],
    particles_per_cell=ppc,
    # c_part_max=1.0,
    mass=1.0,
    charge=-1.0,
    number_density=0.0,  # 'CD2-profile.h5/density_group/E_profile',
    # mean_velocity=[0.5, 0., 0.],
    # time_frozen=0.0,
    boundary_conditions=[
        ["stop", "stop"],
        ["periodic", "periodic"],
    ],
)


Collisions(
    species1=["Deuterium"],
    species2=["Deuterium"],
    # coulomb_log=0.001,
    nuclear_reaction=["He3", "Neutron"],
    debug_every=10,
)


every = 400


DiagParticleBinning(
    deposited_quantity="weight",
    every=every,
    flush_every=5 * every,
    species=["Neutron"],
    axes=[["ekin", 0.0, 2.0, 10000, "edge_inclusive"]],  # 0keV-1MeV
    # axes=[["ekin", 0.002, 20, 1000, "logscale", "edge_inclusive"]],  # 1keV-10MeV
)

DiagParticleBinning(
    deposited_quantity="weight",
    every=every,
    flush_every=5 * every,
    species=["Electron"],
    axes=[["ekin", 0.0, 2.0, 10000, "edge_inclusive"]],  # 0keV-1MeV
    # axes=[["ekin", 0.002, 20, 1000, "logscale", "edge_inclusive"]],  # 1keV-10MeV
)

DiagParticleBinning(
    deposited_quantity="weight",
    every=every,
    flush_every=5 * every,
    species=["Deuterium"],
    axes=[["ekin", 0.0, 2.0, 10000, "edge_inclusive"]],  # 0keV-1MeV
    # axes=[["ekin", 0.002, 20, 1000, "logscale", "edge_inclusive"]],  # 1keV-10MeV
)

DiagScalar(
    every=every,
    vars=["Dens_Neutron", "Ntot_Neutron"],
    precision=5,
)

outlog

                    _            _                                                                            
  ___           _  | |        _  \ \   Version : ??-??                                                        
 / __|  _ __   (_) | |  ___  (_)  | |                                                                         
 \__ \ | '  \   _  | | / -_)  _   | |                                                                         
 |___/ |_|_|_| |_| |_| \___| |_|  | |                                                                         
                                 /_/                                                                          
                                         
Reading the simulation parameters                                                                  [333/1866]│
 --------------------------------------------------------------------------------                             
 HDF5 version 1.12.0                                                                                          
 Python version 3.8.10                                                                                        
 Code run to here 0                                                                                           
 Code run to here 1                                                                                           
 Code run to here 2                                                                                           
         Parsing pyinit.py                                                                                    
         Parsing ??-??                                                                                        
 Code run to here 3                                                                                           
         Parsing pyprofiles.py                                                                                
         Parsing MyDDfusion.py                                                                                
         Parsing pycontrol.py                                                                                 
         Check for function preprocess()                                                                      
         Calling python preprocess          
/home/wyj/.local/lib/python3.8/site-packages/h5py/__init__.py:36: UserWarning: h5py is running again[318/1866$
12.0 when it was built against 1.12.2, this may cause problems                                                
  _warn(("h5py is running against HDF5 {0} when it was built against {1}, "                                   
Warning! ***HDF5 library version mismatched error***                                                          
The HDF5 header files used to compile this application do not match                                           
the version used by the HDF5 library to which this application is linked.                                     
Data corruption or segmentation faults may occur if the application continues.                                
This can happen when an application was compiled by one version of HDF5 but                                   
linked with a different version of static or shared HDF5 library.                                             
You should recompile the application or check your shared library related                                     
settings such as 'LD_LIBRARY_PATH'.                                                                           
'HDF5_DISABLE_VERSION_CHECK' environment variable is set to 1, application will                               
continue at your own risk.                                                                                    
Headers are 1.12.2, library is 1.12.0                                                                         
            SUMMARY OF THE HDF5 CONFIGURATION                                                                 
            =================================                                                                 
                                                                                                              
General Information:
-------------------                                                                                 [300/1866]
                   HDF5 Version: 1.12.0                                                                       
                  Configured on: Sat Jun  5 20:40:41 CST 2021                                                 
                  Configured by: fcb@t2                                                                       
                    Host system: x86_64-unknown-linux-gnu                                                     
              Uname information: Linux t2 5.4.0-74-generic #83-Ubuntu SMP Sat May 8 02:35:39 UTC 2021 x86_64 x
86_64 x86_64 GNU/Linux                                                                                        
                       Byte sex: little-endian                                                                
             Installation point: /usr/local/hdf5                                                              
                                                                                                              
Compiling Options:                                                                                            
------------------                                                                                            
                     Build Mode: production                                                                   
              Debugging Symbols: no                                                                           
                        Asserts: no                                                                           
                      Profiling: no                                                                           
             Optimization Level: high    
Linking Options:                                                                                    [282/1866]
----------------                                                                                              
                      Libraries: static, shared                                                               
  Statically Linked Executables:                                                                              
                        LDFLAGS:                                                                              
                     H5_LDFLAGS:                                                                              
                     AM_LDFLAGS:                                                                              
                Extra libraries: -lz -ldl -lm                                                                 
                       Archiver: ar                                                                           
                       AR_FLAGS: cr                                                                           
                         Ranlib: ranlib                                                                       
                                                                                                              
Languages:                                                                                                    
----------                                                                                                    
                              C: yes                                                                          
                     C Compiler: /usr/local/openmpi/bin/mpicc ( Configured with: ../src/configure -v --with-pk
gversion='Ubuntu 9.3.0-17ubuntu1~20.04' --with-bugurl=file:///usr/share/doc/gcc-9/README.Bugs --enable-languag
es=c,ada,c++,go,brig,d,fortran,objc,obj-c++,gm2 --prefix=/usr --with-gcc-major-version-only --progra[265/1866$
9 --program-prefix=x86_64-linux-gnu- --enable-shared --enable-linker-build-id --libexecdir=/usr/lib --without-
included-gettext --enable-threads=posix --libdir=/usr/lib --enable-nls --enable-clocale=gnu --enable-libstdcxx
-debug --enable-libstdcxx-time=yes --with-default-libstdcxx-abi=new --enable-gnu-unique-object --disable-vtabl
e-verify --enable-plugin --enable-default-pie --with-system-zlib --with-target-system-zlib=auto --enable-objc-
gc=auto --enable-multiarch --disable-werror --with-arch-32=i686 --with-abi=m64 --with-multilib-list=m32,m64,mx
32 --enable-multilib --with-tune=generic --enable-offload-targets=nvptx-none=/build/gcc-9-HskZEa/gcc-9-9.3.0/d
ebian/tmp-nvptx/usr,hsa --without-cuda-driver --enable-checking=release --build=x86_64-linux-gnu --host=x86_64
-linux-gnu --target=x86_64-linux-gnu built with gcc version 9.3.0 (Ubuntu 9.3.0-17ubuntu1~20.04))             
                       CPPFLAGS:                                                                              
                    H5_CPPFLAGS: -D_GNU_SOURCE -D_POSIX_C_SOURCE=200809L   -DNDEBUG -UH5_DEBUG_API            
                    AM_CPPFLAGS:                                                                              
                        C Flags:                                                                              
                     H5 C Flags:  -std=c99  -Wall -Wcast-qual -Wconversion -Wextra -Wfloat-equal -Wformat=2 -W
init-self -Winvalid-pch -Wmissing-include-dirs -Wno-c++-compat -Wno-format-nonliteral -Wshadow -Wundef -Wwrite
-strings -pedantic -Wbad-function-cast -Wcast-align -Wdeclaration-after-statement -Wdisabled-optimization -Wmi
ssing-declarations -Wmissing-prototypes -Wnested-externs -Wold-style-definition -Wpacked -Wredundant[249/1866$
trict-prototypes -Wswitch-enum -Wswitch-default -Wunused-macros -Wunsafe-loop-optimizations -Wlogical-op -Wlar
ger-than=2560 -Wsync-nand -Wframe-larger-than=16384 -Wpacked-bitfield-compat -Wstrict-overflow=5 -Wjump-misses
-init -Wunsuffixed-float-constants -Wdouble-promotion -Wtrampolines -Wstack-usage=8192 -Wvector-operation-perf
ormance -Wdate-time -Warray-bounds=2 -Wc99-c11-compat -Wnull-dereference -Wunused-const-variable -Wduplicated-
cond -Whsa -Wnormalized -Walloc-zero -Walloca -Wduplicated-branches -Wformat-overflow=2 -Wformat-truncation=2 
-Wimplicit-fallthrough=5 -Wrestrict -Wattribute-alias -Wcast-align=strict -Wshift-overflow=2 -Wattribute-alias
=2 -Wmissing-profile -fstdarg-opt -s -Wno-aggregate-return -Wno-inline -Wno-missing-format-attribute -Wno-miss
ing-noreturn -Wno-suggest-attribute=const -Wno-suggest-attribute=pure -Wno-suggest-attribute=noreturn -Wno-sug
gest-attribute=format -Wno-suggest-attribute=cold -Wno-suggest-attribute=malloc -O3                           
                     AM C Flags:                                                                              
               Shared C Library: yes                                                                          
               Static C Library: yes                                                                          
                                                                                                              
                                                                                                              
                        Fortran: no  
                           C++: no                                                                 [232/1866]│
                                                                                                              
                           Java: no                                                                           
                                                                                                              
                                                                                                              
Features:                                                                                                     
---------                                                                                                     
                   Parallel HDF5: yes                                                                         
Parallel Filtered Dataset Writes: yes                                                                         
              Large Parallel I/O: yes                                                                         
              High-level library: yes                                                                         
                Build HDF5 Tests: yes                                                                         
                Build HDF5 Tools: yes                                                                         
                    Threadsafety: no                                                                          
             Default API mapping: v112                                                                        
  With deprecated public symbols: yes            
          I/O filters (external): deflate(zlib)                                                     [216/1866]
                             MPE:                                                                             
                   Map (H5M) API: no                                                                          
                      Direct VFD: no                                                                          
              (Read-Only) S3 VFD: no                                                                          
            (Read-Only) HDFS VFD: no                                                                          
                         dmalloc: no                                                                          
  Packages w/ extra debug output: none                                                                        
                     API tracing: no                                                                          
            Using memory checker: no                                                                          
 Memory allocation sanity checks: no                                                                          
          Function stack tracing: no                                                                          
       Strict file format checks: no                                                                          
    Optimization instrumentation: no                                                                          
         Calling python _smilei_check                                                                         
         Calling python _prepare_checkpoint_dir                                                               
         Calling python _keep_python_running() :          

[WARNING](0) src/Params/Params.cpp:642 (Params) Resources allocated 104 underloaded regarding the total number
 of patches 64                                                                                                
                                                                                                              
[WARNING](0) src/Params/Params.cpp:660 (Params) Patches distribution: hilbertian                              
                                                                                                              
[WARNING](0) src/Params/Params.cpp:1052 (compute) simulation_time has been redefined from 1256.637061 to 1256.
620845 to match timestep.

Geometry: 2Dcartesian                                                                                        │
 --------------------------------------------------------------------------------                             
         Interpolation order : 2                                                                              
         Maxwell solver : Yee                                                                                 
         simulation duration = 1256.620845,   total number of iterations = 40226                              
         timestep = 0.031239 = 0.900000 x CFL,   time resolution = 32.011247                                  
         Grid length: 25.1327, 12.5664                                                                        
         Cell length: 0.0490874, 0.0490874, 0                                                                 
         Number of cells: 512, 256                                                                            
         Spatial resolution: 20.3718, 20.3718                                                                 
         cell sorting: Activated          

 Electromagnetic boundary conditions                                                                          
 --------------------------------------------------------------------------------                             
         xmin silver-muller, absorbing vector [1, 0]                                                          
         xmax silver-muller, absorbing vector [-1, -0]                                                        
         ymin periodic                                                                                        
         ymax periodic                                                                                        
                                                                                                              
                                                                                                              
 Vectorization:                                                                                               
 --------------------------------------------------------------------------------                             
         Mode: off                                                                                            
                                                                                                              
                                                                                                              
 Initializing MPI                                                                                             
 --------------------------------------------------------------------------------      
 2D built-in profile `constant` (value: 16.000000)                                                  [160/1866]
 2D built-in profile `constant` (value: 16.000000)                                                            
 2D built-in profile `constant` (value: 16.000000)                                                            
 2D built-in profile `constant` (value: 16.000000)                                                            
         applied topology for periodic BCs in y-direction                                                     
         MPI_THREAD_MULTIPLE enabled                                                                          
         Number of MPI processes: 1                                                                           
         Number of threads per MPI process : 104                                                              
                                                                                                              
         Number of patches: 8 x 8                                                                             
         Number of cells in one patch: 64 x 32                                                                
         Dynamic load balancing: never                                                                        
                                                                                                              
                                                                                                              
 Initializing the restart environment                                                                         
 --------------------------------------------------------------------------------    

Initializing species                                                                                         │
 --------------------------------------------------------------------------------                             
                                                                                                              
         Creating Species #0: Deuterium                                                                       
                 > Pusher: boris                                                                              
                 > Boundary conditions: stop stop periodic periodic                                           
                 > Density profile: 2D from file `CD2-profile.h5/density_group/D_profile`                     
                                                                                                              
         Creating Species #1: Carbon                                                                          
                 > Pusher: boris                                                                              
                 > Boundary conditions: stop stop periodic periodic                                           
                 > Density profile: 2D from file `CD2-profile.h5/density_group/C_profile`

         Creating Species #2: He3                                                                   [128/1866]
                 > Pusher: boris                                                                              
                 > Boundary conditions: stop stop periodic periodic                                           
                 > Density profile: 2D built-in profile `constant` (value: 0.000000)                          
                                                                                                              
         Creating Species #3: Neutron                                                                         
                 > Pusher: boris                                                                              
                 > Boundary conditions: stop stop periodic periodic                                           
                 > Density profile: 2D built-in profile `constant` (value: 0.000000)                          
                                                                                                              
         Creating Species #4: Electron                                                                        
                 > Pusher: boris                                                                              
                 > Boundary conditions: stop stop periodic periodic                                           
                 > Density profile: 2D built-in profile `constant` (value: 0.000000)                    

Initializing laser parameters                                                                      [112/1866]│
 --------------------------------------------------------------------------------                             
                Laser #0: separable profile                                                                   
                        omega              : 1                                                                
                        chirp_profile      : 1D built-in profile `tconstant` (0.000000)                       
                        time envelope      : 1D built-in profile `tgaussian` (start: 0.000000, duration: 207.3
45115, sigma: 3203.736598, center: 94.247780, order: 2.000000)                                                
                        space envelope (y) : 1D built-in profile `constant` (value: 0.000000)                 
                        space envelope (z) : 1D built-in profile `constant` (value: 5.000000)                 
                        phase          (y) : 1D built-in profile `constant` (value: 0.000000)                 
                        phase          (z) : 1D built-in profile `constant` (value: -0.000000)                
                delay phase      (y) : 0                                                                      
                delay phase      (z) : 0                                                                      
         Parameters for collisions #0 :                                                                       
                 Intra collisions within species (0)                                                          
                 Coulomb logarithm: 0.000000                                                                  
                 Debug every 10 timesteps                                                                     
                 Collisional nuclear reaction D-D fusion
                                                                                                              
                                                                                                              
 Initializing Patches                                                                                         
 --------------------------------------------------------------------------------                             
         First patch created                                                                                  
                 Approximately 10% of patches created                                                         
                 Approximately 20% of patches created                                                         
                 Approximately 30% of patches created                                                         
                 Approximately 40% of patches created                                                         
                 Approximately 50% of patches created                                                         
                 Approximately 60% of patches created                                                         
                 Approximately 70% of patches created                                                         
                 Approximately 80% of patches created                                                         
                 Approximately 90% of patches created                                                         
         All patches created                       
Creating Diagnostics, antennas, and external fields                                                          │
 --------------------------------------------------------------------------------                             
         Created ParticleBinning #0: species Neutron                                                          
                 Axis ekin from 0 to 2 in 10000 steps [EDGE INCLUSIVE]                                        
         Created ParticleBinning #1: species Electron                                                         
                 Axis ekin from 0 to 2 in 10000 steps [EDGE INCLUSIVE]                                        
         Created ParticleBinning #2: species Deuterium                                                        
                 Axis ekin from 0 to 2 in 10000 steps [EDGE INCLUSIVE]                                        
                                                                                                              
                                                                                                              
 finalize MPI                                                                                                 
 --------------------------------------------------------------------------------                             
         Done creating diagnostics, antennas, and external fields 
 Minimum memory consumption (does not include all temporary buffers)                                          
 --------------------------------------------------------------------------------                             
              Particles: Master 143 MB;   Max 143 MB;   Global 0.14 GB                                        
                 Fields: Master 16 MB;   Max 16 MB;   Global 0.0158 GB                                        
            scalars.txt: Master 0 MB;   Max 0 MB;   Global 0 GB                                               
    ParticleBinning0.h5: Master 0 MB;   Max 0 MB;   Global 7.45e-05 GB                                        
    ParticleBinning1.h5: Master 0 MB;   Max 0 MB;   Global 7.45e-05 GB                                        
    ParticleBinning2.h5: Master 0 MB;   Max 0 MB;   Global 7.45e-05 GB                                        
                                                                                                              
                                                                                                              
 Initial fields setup                                                                                         
 --------------------------------------------------------------------------------                             
         Applying external fields at time t = 0                                                               
         Applying prescribed fields at time t = 0                                                             
         Applying antennas at time t = 0      
                                                                                                             │
 Open files & initialize diagnostics                                                                          
 --------------------------------------------------------------------------------                             
                                                                                                              
                                                                                                              
 Running diags at time t = 0                                                                                  
 --------------------------------------------------------------------------------                             
                                                                                                              
                                                                                                              
 Species creation summary                                                                                     
 --------------------------------------------------------------------------------                             
                 Species 0 (Deuterium) created with 751536 particles                                          
                 Species 1 (Carbon) created with 751536 particles                                             
                 Species 2 (He3) created with 0 particles         
                 Species 3 (Neutron) created with 0 particles                                        [32/1866]
                 Species 4 (Electron) created with 0 particles                                                
                                                                                                              
                                                                                                              
 Expected disk usage (approximate)                                                                            
 --------------------------------------------------------------------------------                             
         WARNING: disk usage by non-uniform particles maybe strongly underestimated,                          
            especially when particles are created at runtime (ionization, pair generation, etc.)              
                                                                                                              
         Expected disk usage for diagnostics:                                                                 
                 File scalars.txt: 4.51 K                                                                     
                 File ParticleBinning0.h5: 7.77 M                                                             
                 File ParticleBinning1.h5: 7.77 M                                                             
                 File ParticleBinning2.h5: 7.77 M                                                             
         Total disk usage for diagnostics: 23.31 M                                                            
                                                                                                              
                                                   
                                                                                                    [16/1866]│
                                                                                                              
 Keeping or closing the python runtime environment                                                            
 --------------------------------------------------------------------------------                             
         Checking for cleanup() function:                                                                     
         python cleanup function does not exist                                                               
         Closing Python                                                                                       
                                                                                                              
                                                                                                              
 Time-Loop started: number of time-steps n_time = 40226                                                       
 --------------------------------------------------------------------------------                             
                                                                                                              
[WARNING](0) src/Params/Params.cpp:1385 (print_timestep_headers) The following `push time` assumes a global nu
mber of 104 cores (hyperthreading is unknown)                                                                 
      timestep       sim time   cpu time [s]   (    diff [s] )   push time [ns]                               
    4022/40226     1.2566e+02     1.0048e+03   (  1.0048e+03 )            4920                                
    8044/40226     2.5130e+02     2.0287e+03   (  1.0239e+03 )            4961                                
   12066/40226     3.7695e+02     3.0853e+03   (  1.0566e+03 )            5051    
Stack trace (most recent call last) in thread 2180634:                                                        
#7    Object "[0xffffffffffffffff]", at 0xffffffffffffffff, in                                                
#6    Object "/lib/x86_64-linux-gnu/libc.so.6", at 0x7f567063b132, in clone                                   
#5    Object "/lib/x86_64-linux-gnu/libpthread.so.0", at 0x7f5670bd4608, in                                   
#4    Object "/usr/lib/x86_64-linux-gnu/libgomp.so.1", at 0x7f567074378d, in                                  
#3    Object "../build/smilei", at 0x5603fb36320d, in                                                         
#2    Object "../build/smilei", at 0x5603fb2b712f, in VectorPatch::dynamics(Params&, SmileiMPI*, SimWindow*, R
adiationTables&, MultiphotonBreitWheelerTables&, double, Timers&, int)                                        
#1    Object "../build/smilei", at 0x5603fb3762d5, in SpeciesV::dynamics(double, unsigned int, ElectroMagn*, P
arams&, bool, PartWalls*, Patch*, SmileiMPI*, RadiationTables&, MultiphotonBreitWheelerTables&, std::vector<Di
agnostic*, std::allocator<Diagnostic*> >&)                                                                    
#0    Object "../build/smilei", at 0x5603fb375896, in SpeciesV::computeParticleCellKeys(Params&, Particles*, i
nt*, int*, unsigned int, unsigned int)                                                                        
Segmentation fault (Address not mapped to object [0x5601fdb15110])                                            
Segmentation fault (core dumped)

@mccoys
Copy link
Contributor

mccoys commented Apr 18, 2023

Are you able to reproduce the bug with a smaller simulation?

@mccoys
Copy link
Contributor

mccoys commented Apr 18, 2023

Please also provide an input that does not rely on external resources (Box.txt, etc.)

@xiaowang119
Copy link
Author

Here is a new inputfile which has smaller scale and don't rely on any external resources. But the same error still occurs!

@mccoys
Copy link
Contributor

mccoys commented Apr 20, 2023

For the record I paste the input here

# ----------------------------------------------------------------------------------------
# 					SIMULATION PARAMETERS FOR THE PIC-CODE SMILEI
# ----------------------------------------------------------------------------------------

import math

# Reference
l0 = 2.0 * math.pi  # laser wavelength 800nm/1um (2*pi*lr)
t0 = l0  # optical cicle 2.66851fs/3.333fs

# Simulation parameters for 800nu
# lm = l0 * 5.0 / 4.0  # 1um
# lr = 8e-7 / (2.0 * math.pi)  # show the value of unit of length in smilei as SI unit
# tm = 5.0 * math.pi / 2.0  # 3.33fs

# Simulation parameters for 1um
lm = l0  # 1um
lr = 1e-6 / (2.0 * math.pi)  # show the value of unit of length in smilei as SI unit
tm = t0  # 3.33fs


Lsim = [1.0 * lm, 1.0 * lm]  # length of the simulation  4um × 2um
# Lsim = [5.0 * lm, 15.0 * lm]
# Lcell = [0.01*l0, 0.01*l0]
resx = 120.0  # nb of cells in on a lm
resy = 120.0
Tsim = 200.0 * t0  # duration of the simulation for 10 laser wavelength (about 48 tm)
# rest = 60.              # time of timestep in one optical cycle

# Laser
omega = 1.0  # = 2PI/t0
a0 = 5.0  # 8.4 、10 、11.85

# particles in per cell
ppc = 16


def densityCarbon(x, y):
    density = 34.6643
    if (x >= 0.2 * Lsim[0] and x <= 0.8 * Lsim[0]) and (
        y >= 0.2 * Lsim[1] and y <= 0.8 * Lsim[1]
    ):
        return density
    else:
        return 0.0


def densityDeuterium(x, y):
    density = 34.6643 * 2.0
    if (x >= 0.2 * Lsim[0] and x <= 0.8 * Lsim[0]) and (
        y >= 0.2 * Lsim[1] and y <= 0.8 * Lsim[1]
    ):
        return density
    else:
        return 0.0


Main(
    geometry="2Dcartesian",
    interpolation_order=2,
    # reference_angular_frequency_SI=2*math.pi*3e8/1.e-6/0.8,  # Lr=0.8/2pi
    reference_angular_frequency_SI=3e8 / lr,  # ωr = c/lr
    grid_length=Lsim,
    cell_length=[lm / resx, lm / resx],  # [l0/resx, l0/resx],
    number_of_patches=[8, 8],
    # timestep=t0/rest,
    # timestep_over_CFL=0.6,
    timestep_over_CFL=0.9,
    simulation_time=Tsim,
    EM_boundary_conditions=[
        ["silver-muller"],
        ["periodic"],
    ],
    # print_every = 1,
    cluster_width=1,
)


LaserPlanar1D(
    box_side="xmin",
    a0=a0,
    omega=omega,
    polarization_phi=0.0,
    ellipticity=0.0,
    # time_envelope=tconstant(),
    time_envelope=tgaussian(
        start=0.0, duration=33 * t0, fwhm=15.0 * t0, center=15.0 * t0
    ),
)

# LaserGaussian2D(
#     box_side="xmin",
#     a0=a0,  # 电磁矢势,用于控制激光强度
#     omega=omega,
#     focus=[2.0 * lm, 1.0 * lm],
#     waist=4.0 * lm,
#     # focus=[4.0 * lm, 7.5 * lm],
#     # waist=2 * lm,  # 10 * lm,
#     incidence_angle=0,
#     polarization_phi=0,
#     ellipticity=0,
#     # time_envelope=tconstant(),
#     time_envelope=tgaussian(
#         start=0.0, duration=40 * tm, fwhm=15.0 * tm, center=15.0 * tm
#     ),
# )


# LoadBalancing(
#     initial_balance=True,
#     every=100,
#     cell_load=1.0,
#     frozen_particle_load=0.1,
# )


# Deuterium
Species(
    name="Deuterium",
    position_initialization="regular",
    momentum_initialization="cold",
    ionization_model="tunnel",
    ionization_electrons="Electron",
    # temperature=[5.0e-8],
    particles_per_cell=ppc,
    # c_part_max=1.0,
    mass=3670.03,  # 3675.18,
    charge=0.0,
    atomic_number=1,
    number_density=densityDeuterium,
    # mean_velocity=[0.5, 0., 0.],
    # time_frozen=0.0,
    boundary_conditions=[
        ["stop", "stop"],
        ["periodic", "periodic"],
    ],
)

# Carbon
Species(
    name="Carbon",
    position_initialization="regular",
    momentum_initialization="cold",
    ionization_model="tunnel",
    ionization_electrons="Electron",
    # temperature=[5.0e-8],
    particles_per_cell=ppc,
    # c_part_max=1.0,
    mass=21866.04,
    charge=0.0,
    atomic_number=6,
    number_density=densityCarbon,
    # mean_velocity=[-0.5, 0., 0.],
    # time_frozen=0.0,
    boundary_conditions=[
        ["stop", "stop"],
        ["periodic", "periodic"],
    ],
)

# Helium-3
Species(
    name="He3",
    position_initialization="regular",
    momentum_initialization="cold",
    ionization_model="tunnel",
    ionization_electrons="Electron",
    # temperature=[5.0e-8],
    particles_per_cell=ppc,
    # c_part_max=1.0,
    mass=5495.66,
    charge=0.0,
    atomic_number=2,
    number_density=0.0,  # 'CD2-profile.h5/density_group/C_profile',
    # mean_velocity=[-0.5, 0., 0.],
    # time_frozen=0.0,
    boundary_conditions=[
        ["stop", "stop"],
        ["periodic", "periodic"],
    ],
)

# Neutron
Species(
    name="Neutron",
    position_initialization="regular",
    momentum_initialization="mj",
    # temperature=[5.0e-8],
    particles_per_cell=ppc,
    # c_part_max=1.0,
    mass=1822.17,
    charge=0.0,
    atomic_number=0,
    number_density=0.0,  # 'CD2-profile.h5/density_group/C_profile',
    # mean_velocity=[-0.5, 0., 0.],
    # time_frozen=0.0,
    boundary_conditions=[
        ["stop", "stop"],
        ["periodic", "periodic"],
    ],
)

# Electron
Species(
    name="Electron",
    position_initialization="regular",
    momentum_initialization="mj",
    temperature=[5.0e-8],
    particles_per_cell=ppc,
    # c_part_max=1.0,
    mass=1.0,
    charge=-1.0,
    number_density=0.0,  # 'CD2-profile.h5/density_group/E_profile',
    # mean_velocity=[0.5, 0., 0.],
    # time_frozen=0.0,
    boundary_conditions=[
        ["stop", "stop"],
        ["periodic", "periodic"],
    ],
)

Collisions(
    species1=["Deuterium"],
    species2=["Deuterium"],
    # coulomb_log=0.001,
    nuclear_reaction=["He3", "Neutron"],
    # nuclear_reaction_multiplier=1.0,
    debug_every=10,
)


every = 400

DiagParticleBinning(
    deposited_quantity="weight",
    every=every,
    flush_every=5 * every,
    species=["Neutron"],
    axes=[["ekin", 0.0, 2.0, 10000, "edge_inclusive"]],  # 0keV-1MeV
    # axes=[["ekin", 0.002, 20, 1000, "logscale", "edge_inclusive"]],  # 1keV-10MeV
)

DiagParticleBinning(
    deposited_quantity="weight",
    every=every,
    flush_every=5 * every,
    species=["Electron"],
    axes=[["ekin", 0.0, 2.0, 10000, "edge_inclusive"]],  # 0keV-1MeV
    # axes=[["ekin", 0.002, 20, 1000, "logscale", "edge_inclusive"]],  # 1keV-10MeV
)

DiagParticleBinning(
    deposited_quantity="weight",
    every=every,
    flush_every=5 * every,
    species=["Deuterium"],
    axes=[["ekin", 0.0, 2.0, 10000, "edge_inclusive"]],  # 0keV-1MeV
    # axes=[["ekin", 0.002, 20, 1000, "logscale", "edge_inclusive"]],  # 1keV-10MeV
)

# DiagFields(
#     # name = "my field diag",
#     every=every,
#     flush_every=5 * every,
#     fields=["Ex", "Ey", "Ez", "Bx", "By", "Bz"],
#     # subgrid = None
# )

DiagScalar(
    every=every,
    vars=["Dens_Neutron", "Ntot_Neutron"],
    precision=5,
)

@mccoys
Copy link
Contributor

mccoys commented Apr 20, 2023

At which timestep do you see the error occur? Is this reproducible?

@mccoys
Copy link
Contributor

mccoys commented Apr 20, 2023

I was able to run your reduced simulation without error. Please specify your version of smilei (and where you got it) and of MPI (mpirun --version). Is your output log for the reduced simulation identical?

@xiaowang119
Copy link
Author

After simplifying the code overhead, I ran it again and encountered the same error as before when it reached 30%. Strangely, now when I run it again, it seems to be working properly again. I have been using Smilei-4.7.tar.gz downloaded from GitHub, and the version of MPI is mpirun (Open MPI) 4.1.1.

I will make further attempts.

@xiaowang119
Copy link
Author

I have carried out simulations of two sizes and repeated each three times. The same error occurred each time, but the timing of the error was not consistent. Attached are my namelist and outlog files.

@mccoys
Copy link
Contributor

mccoys commented Apr 28, 2023

Can you try using less threads? Like 16? You are using way too many compared to the number of patches.

Your pushtime is catastrophic because of this, and I wonder whether it could cause memory issues.

@mccoys
Copy link
Contributor

mccoys commented Apr 28, 2023

Additionally, I don't think you have provided the exact same input file as that you have used because the basic data I obtain at the start of the log is different from yours

@xiaowang119
Copy link
Author

I have tried repeatedly to run the program using mpirun -n 4 smilei namelist.py and set OMP_NUM_THREADS to 4 or 8; however, sometimes it reports an error and other times it runs normally.

I'm sorry, but I have also been puzzled by this bug. I am no longer sure if it is caused by the fusion part, as this error can occur with changes in simulation scale, grid division, and even density distribution. The most lethal thing is that even without any changes, you can repeatedly run it and get different results.

@xiaowang119
Copy link
Author

The only thing that remains unchanged is the error message.

Stack trace (most recent call last) in thread 78755:#7 Object "[0xffffffffffffffff]", at 0xffffffffffffffff, in #6 Object "/usr/lib/x86_64-linux-gnu/libc.so.6", at 0x7f04f9567132, in clone
#5 Object "/usr/lib/x86_64-linux-gnu/libpthread.so.0", at 0x7f04f9b15608, in #4 Object "/usr/lib/x86_64-linux-gnu/libgomp.so.1", at 0x7f04f966f78d, in
#3 Object "/home/Data/wyj/Smilei-4.7/build/smilei", at 0x55e3aee6e1ed, in
#2 Object "/home/Data/wyj/Smilei-4.7/build/smilei", at 0x55e3aed8ba0f, in VectorPatch::dynamics(Params&, SmileiMPI*, SimWindow*, RadiationTables&, MultiphotonBreitWheelerTables&, double, Timers&, int)
#1 Object "/home/Data/wyj/Smilei-4.7/build/smilei", at 0x55e3aee8fd25, in SpeciesV::dynamics(double, unsigned int, ElectroMagn*, Params&, bool, PartWalls*, Patch*, SmileiMPI*, RadiationTables&, MultiphotonBreitWheelerTables&, std::vector<Diagnostic*, std::allocator<Diagnostic*> >&)
#0 Object "/home/Data/wyj/Smilei-4.7/build/smilei", at 0x55e3aee8f2e6, in SpeciesV::computeParticleCellKeys(Params&, Particles*, int*, int*, unsigned int, unsigned int)
Segmentation fault (Address not mapped to object [0x55e1b12ec7a0])

@mccoys
Copy link
Contributor

mccoys commented Apr 29, 2023

Could you try with pure MPI (no openmp), using OMP_NUM_THREADS set to 1?

If it works, try to recompile with the no_mpi_tm option:

make clean
make config=no_mpi_tm

Then run again with openmp activated

@xiaowang119
Copy link
Author

Thank you a lot! According to your previous advice, I carried out the operation (let OMP_NUM_THREADS=1) and the previous error magically disappeared. I repeatedly ran it in a loop and modified the initial conditions, and now I am confident that it can run normally. So what caused this?

@mccoys
Copy link
Contributor

mccoys commented May 3, 2023

Have you tried what I indicated above? no_mpi_tm

If it works again then the problem is that mpi was not compiled with the THREAD_MULTIPLE option

@xiaowang119
Copy link
Author

I just tried with pure MPI, then it worked well. So I will continue to push forward with my work in this way for now. After I'm done with this busy period, I will come back and test the recompile option.

@mccoys
Copy link
Contributor

mccoys commented May 3, 2023

Let me close the issue. Please reopen if the solution did not work in the end

@mccoys mccoys closed this as completed May 3, 2023
@xiaowang119
Copy link
Author

Recently, I have try make config=no_mpi_tm and run again with openmp activated. I set the environment variable export OMP_NUM_THREADS=25 before running mpirun -n 4 smilei namelist.py. But each MPI process calls far fewer than 25 openMP threads.

Worst of all, the error mentioned above will still occur. It seems to work well only with pure MPI.

@mccoys
Copy link
Contributor

mccoys commented Jul 30, 2023

Is this still happening with the same previous input files?

And did you make clean before compiling?

@xiaowang119
Copy link
Author

Yes, I did make clean, and uesed the previous namelist.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants