• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

wexlergroup / FreeBird.jl / 17921213087

22 Sep 2025 04:03PM UTC coverage: 90.929% (-4.3%) from 95.254%
17921213087

Pull #114

github

web-flow
Merge a9c21e077 into c53e0fa4d
Pull Request #114: Generalization of potentials; bump version to v0.2.

202 of 289 new or added lines in 12 files covered. (69.9%)

3 existing lines in 1 file now uncovered.

1674 of 1841 relevant lines covered (90.93%)

70439.36 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

0.0
/src/AbstractPotentials/gupta.jl
1
abstract type GuptaParameterSets{T} <: SingleComponentPotential{T} end
2

3
"""
4
    struct GuptaParameters
5
The `GuptaParameters` struct represents the parameters for the Gupta potential (a many-body potential, also known as the second-moment approximation tight-binding potential or SMA-TB).
6

7
# Formula
8
The Gupta potential is given by:
9
```math
10
E_i = \\sum_j A \\exp\\left(-p \\left(\\frac{r_{ij}}{r_0} - 1\\right)\\right) - \\sqrt{\\sum_j \\xi^2 \\exp\\left(-2q \\left(\\frac{r_{ij}}{r_0} - 1\\right)\\right)}
11
```
12
where:
13
- ``E_i`` is the combined attraction and repulsion energy for atom ``i``.
14
- ``r_{ij}`` is the distance between atoms ``i`` and ``j``.
15
- ``A`` is the repulsive energy scale.
16
- ``\\xi`` is the attractive energy scale.
17
- ``p`` is the exponent for the repulsive term.
18
- ``q`` is the exponent for the attractive term.
19
- ``r_0`` is the nearest-neighbor distance in the bulk material.
20
- The potential is typically truncated at a cutoff distance, defined as a multiple of ``r_0``.
21
See Cleri and Rosato 1993 [Phys. Rev. B 48, 22](https://doi.org/10.1103/PhysRevB.48.22) for more details.
22

23
# Fields
24
- `A::typeof(1.0u"eV")`: The repulsive energy scale of the potential.
25
- `ξ::typeof(1.0u"eV")`: The attractive energy scale of the potential.
26
- `p::Float64`: The exponent for the repulsive term.
27
- `q::Float64`: The exponent for the attractive term.
28
- `r0::typeof(1.0u"Å")`: The equilibrium distance for the potential.
29
- `cutoff::Float64`: The cutoff distance for the potential, in units of `r0`.
30
"""
31
struct GuptaParameters <: GuptaParameterSets{ManyBody}
32
    A::typeof(1.0u"eV")
33
    ξ::typeof(1.0u"eV")
34
    p::Float64
35
    q::Float64
36
    r0::typeof(1.0u"Å")
37
    cutoff::Float64
38
end
39

40
"""
41
    GuptaParameters(;A=1.0, ξ=1.0, p=10.0, q=5.0, r0=1.0, cutoff=Inf)
42
A constructor for the `GuptaParameters` struct with default values for the Gupta potential with no cutoff.
43
"""
NEW
44
function GuptaParameters(;A=1.0, ξ=1.0, p=10.0, q=5.0, r0=1.0, cutoff=Inf)
×
NEW
45
    return GuptaParameters(A*u"eV", ξ*u"eV", p, q, r0*u"Å", cutoff)
×
46
end
47

48
"""
49
    gupta_attraction_squared(r::typeof(1.0u"Å"), gp::GuptaParameters)
50
Calculate the squared attractive energy term of the Gupta potential for a given interatomic distance `r`
51
and a set of `GuptaParameters`. It is used to define the many-body interaction in the Gupta potential.
52
See `many_body_energy` for more details. The square root is taken when calculating the total energy. See `total_energy`.
53

54
# Arguments
55
- `r::typeof(1.0u"Å")`: The interatomic distance.
56
- `gp::GuptaParameters`: The parameters of the Gupta potential.
57

58
# Returns
59
- The squared attractive energy term of the Gupta potential.
60
"""
NEW
61
function gupta_attraction_squared(r::typeof(1.0u"Å"), gp::GuptaParameters)
×
NEW
62
    if r > gp.cutoff * gp.r0
×
NEW
63
        return 0.0u"eV^2"
×
64
    else 
NEW
65
        return gp.ξ^2 * exp(-2 * gp.q * (r/gp.r0 - 1))
×
66
    end
67
end
68

69
"""
70
    gupta_repulsion(r::typeof(1.0u"Å"), gp::GuptaParameters)
71
Calculate the repulsive energy term of the Gupta potential for a given interatomic distance `r`
72
and a set of `GuptaParameters`. It is used to define the two-body interaction in the Gupta potential.
73
See `two_body_energy` for more details.
74

75
# Arguments
76
- `r::typeof(1.0u"Å")`: The interatomic distance.
77
- `gp::GuptaParameters`: The parameters of the Gupta potential.
78

79
# Returns
80
- The repulsive energy term of the Gupta potential.
81
"""
NEW
82
function gupta_repulsion(r::typeof(1.0u"Å"), gp::GuptaParameters)
×
NEW
83
    if r > gp.cutoff * gp.r0
×
NEW
84
        return 0.0u"eV"
×
85
    else 
NEW
86
        return gp.A * exp(-gp.p * (r/gp.r0 - 1))
×
87
    end 
88
end
89

90
"""
91
    two_body_energy(r::typeof(1.0u"Å"), gp::GuptaParameters)
92
Calculate the two-body repulsive energy between two atoms separated by a distance `r`
93
using the Gupta potential defined by the parameters in `gp`.
94
See `gupta_repulsion` for more details.
95
"""
NEW
96
two_body_energy(r::typeof(1.0u"Å"), gp::GuptaParameters) = gupta_repulsion(r, gp)
×
97

98
"""
99
    many_body_energy(r::typeof(1.0u"Å"), gp::GuptaParameters)
100
Calculate the squared many-body attractive energy contribution from a single atom at a distance `r`
101
using the Gupta potential defined by the parameters in `gp`.
102
See `gupta_attraction_squared` for more details.
103
"""
NEW
104
many_body_energy(r::typeof(1.0u"Å"), gp::GuptaParameters) = gupta_attraction_squared(r, gp)
×
105

106

107
"""
108
    total_energy(energies_two_body::Vector{<:Real}, 
109
                    energies_many_body::Vector{<:Real}, 
110
                    pot::Union{GuptaParameters,CompositeParameterSets{C, GuptaParameters}}) where C
111
Calculate the total energy of a system using the Gupta potential.
112
The total energy is computed by summing the two-body repulsive energies and subtracting the square root of the many-body attractive energies.
113
See `two_body_energy` and `many_body_energy` for more details.
114
"""
NEW
115
total_energy(energies_two_body::Vector{<:Real}, 
×
116
            energies_many_body::Vector{<:Real}, 
NEW
117
            pot::Union{GuptaParameters,CompositeParameterSets{C, GuptaParameters}}) where C = sum(energies_two_body .- sqrt.(energies_many_body)) * u"eV"
×
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc