3
$\begingroup$

I found this source code written by someone:

def get_energy_of_one_atom(atoms_vec, period_box_len__int, atom_index__int, min_atom_distance__float, max_atom_distance__float): """ Evaluates the energy of a single atom """ en = 0 for i in range(len(atoms_vec)): if i == atom_index__int: continue dx = abs(atoms_vec[atom_index__int][0] - atoms_vec[i][0]) dy = abs(atoms_vec[atom_index__int][1] - atoms_vec[i][1]) dx = dx if dx < period_box_len__int / 2 else period_box_len__int - dx dy = dy if dy < period_box_len__int / 2 else period_box_len__int - dy d = math.sqrt(dx ** 2 + dy ** 2) if d < min_atom_distance__float: en += 10000000 elif d < max_atom_distance__float: en += -1 return en 

This source code calculates the energy of one gas atom in a box.

What formula was used here?

Can you supply me with a reference?

$\endgroup$

1 Answer 1

8
$\begingroup$

The formulas that the code is using can be directly read off from the code. The code simulates a two-dimensional periodic box, and calculates the distance of each atom to each other atom, namely d. If d is very small, increase the energy by a very large number. If d is small but not that small, decrease the energy by a very small number.

Obviously what the code does here is to treat all atoms as essentially rigid balls with a finite-ranged attraction potential: $$ V(r) = \left\{\begin{array}{ll}10000000,& r<r_0 \\ -1,& r_0\le r<r_1 \\ 0,& r\ge r_1\end{array} \right. $$ and compute the energy of the total system. The resulting energy is the exact energy of an atom but with an extremely simplified and unrealistic interaction potential. The code is only applicable for calculating the energy of an atom in that particular toy model, and must be modified if realistic potentials (such as the Lennard-Jones potential) are used. There is no need to give a reference; it's even faster to work out the formulas by yourself than to look for a reference.

$\endgroup$
2
  • $\begingroup$ The Lennard-Jones formula for pair potential was supposed to be used here. The coder rather used a formula that is unknown to me. I was asking for a reference so that I can understand in what context it was used. $\endgroup$ Commented Apr 26, 2022 at 7:19
  • 1
    $\begingroup$ If nothing else, this unrealistic potential would probably use fewer clock cycles to calculate than calculating $d^6 - d^{12}$, and might be helpful to use for testing purposes before replacing it with the "real" Lennard-Jones potential later on. $\endgroup$ Commented Apr 26, 2022 at 16:28

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.