1- struct Atoms{D, Q, V<: AbstractVector , C<: NeighbourList , H, T<: AbstractFloat , SM<: AbstractArray } <: Particles
1+ struct Atoms{D, V<: AbstractVector , C<: NeighbourList , H, T<: AbstractFloat , SM<: AbstractArray } <: Particles
22 position:: Vector{SVector{D,T}}
33 species:: V
44 density:: T
@@ -8,7 +8,6 @@ struct Atoms{D, Q, V<:AbstractVector, C<:NeighbourList, H, T<:AbstractFloat, SM<
88 N:: Int
99 d:: Int
1010 box:: SVector{D,T}
11- local_energy:: MVector{Q, T}
1211 neighbour_list:: C
1312 species_list:: H
1413end
@@ -20,15 +19,17 @@ function System(position, species, density::T, temperature::T, model_matrix; lis
2019 d = length (Array (position)[1 ])
2120 energy = Vector {T} (undef, 1 )
2221 box = @SVector fill (T ((N / density)^ (1 / d)), d)
23- local_energy = MVector {N, T} (zeros (T, N))
24- indices = MVector {N, Bool} (falses (N))
2522 maxcut = maximum ([model. rcut for model in model_matrix])
2623 neighbour_list = list_type (box, maxcut, N)
2724 species_list = isa (species[1 ], Integer) ? SpeciesList (species) : nothing
2825 system = Atoms (position, species, density, energy, temperature, model_matrix, N, d, box, neighbour_list, species_list)
2926 build_neighbour_list! (system)
30- system. local_energy .= [compute_energy_particle (system, i) for i in eachindex (system)]
31- system. energy[1 ] = sum (system. local_energy) / 2
27+ local_energy = [compute_energy_particle (system, i, neighbour_list) for i in eachindex (position)]
28+ energy = mean (local_energy) / 2
29+ if isinf (energy) || isnan (energy)
30+ error (" Initial configuration has infinite or NaN energy." )
31+ end
32+ system. energy[1 ] = energy
3233 return system
3334end
3435
0 commit comments