Question about setting a gaussian distribution of charge in granular sphere

The following code simulates a pour of granular spheres with a constant positive charge. I was wondering if there is a simple way to set a Gaussian distribution of charge instead.

It would be great if you could provide an example.

atom_style hybrid sphere charge # Agora permite cargas nas partículas
units si
boundary p p fm
newton off
comm_modify vel yes

Define variables for particles

variable idpackedbed equal 1
variable numpart equal 20
variable numpintloop equal 20
variable rnseed equal 123457
variable diam_mean equal 0.5
variable diam_std equal 0.0001
variable seed_diam equal 125632
variable phi equal 0.8 # packing fraction to fill the cavity
variable numtemps equal 10 # Number of attempts to insert new spheres

Define variables for box

variable boxpartscale_x equal 5
variable boxpartscale_y equal 30
variable boxpartscale_z equal 50
variable x0 equal 0
variable xf equal {boxpartscale_x}*{diam_mean}
variable y0 equal 0
variable yf equal {boxpartscale_y}*{diam_mean}
variable z0 equal 0
variable zf equal {boxpartscale_z}*{diam_mean}

Define regions

region simulation_box block {x0} {xf} {y0} {yf} {z0} {zf}
region box_injec block {x0} {xf} {y0} {yf} {z0} {zf}
create_box 2 simulation_box

Define list neighbors

neighbor 2 bin
neigh_modify delay 0

Define interaction

pair_style hybrid/overlay granular coul/cut 10.0
pair_coeff * * granular hertz 1000.0 50.0 tangential mindlin 1000.0 1.0 0.4
pair_coeff * * coul/cut 0.5 # Define interação de Coulomb com cutoff 0.5

Define timestep

timestep 0.0001

Define integration method

fix 1 all nve/sphere

Define gravitational field

fix 2 all gravity 9.81 vector 0 0 -1 # Gravidade atuando no eixo Z (para baixo)

Define Wall Interaction

fix zlower all wall/gran hooke/history 2000.0 NULL 50.0 NULL 0.5 0 zplane 0.0 NULL

dump mydmp all custom 100 dump.lammpstrj id type diameter q x y z vx vy vz omegax omegay omegaz fx fy fz

Define loop variable

variable varloop loop ${numpintloop}
label loop

variable seed1 equal floor(${varloop}*34512/10000) # Use different seeds each time

Generate a new random diameter for each iteration

variable diam_sphere equal normal({diam_mean},{diam_std},${seed1})

Insert particles with random sizes

fix mypour5 all pour {numpart} 1 {seed1} vol {phi} {numtemps} &
region box_injec diam one ${diam_sphere}

run 1000 # Short run after particle insertion

Assign charge to newly inserted particles (now that atoms exist)

set group all charge 1e-15

next varloop
jump SELF loop

run 80000 # Final longer run
write_data last_step_sim.rest

Please check out this post: Please Read This First: Guidelines and Suggestions for posting LAMMPS questions
It explains basic guidelines for posting here and that includes how to properly typeset quoted text, so that it is properly readable. Yours is not. Didn’t you notice??

If you want a assign a non-uniform charge, you need to replace “1e-15” in

set group all charge 1e-15

with a reference to an atom style variable that uses and expression based on either the “normal()” function to create a random gaussian distribution, or some other expression that would compute the charge for the individual atom based on its position in the box or similar. Please see the documentation for the “set” and the “variable” commands for details.