Skip to content

Commit 8aa5f39

Browse files
author
flibbi
committed
form
1 parent a6a2b37 commit 8aa5f39

7 files changed

Lines changed: 51 additions & 29 deletions

File tree

src/QuantumGaussianDynamics.jl

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -50,12 +50,14 @@ include("external_f.jl")
5050
export Dynamics, Ensemble, ElectricField, WignerDistribution
5151

5252
# Initialization functions
53-
export init_from_dyn, init_ensemble_from_python, init_calculator, fake_field, equilibrium_ensemble
53+
export init_from_dyn,
54+
init_ensemble_from_python, init_calculator, fake_field, equilibrium_ensemble
5455

5556
# Forces and electric fields
56-
export generate_ensemble!, calculate_ensemble!, get_averages!, get_alphabeta, get_correlators
57+
export generate_ensemble!,
58+
calculate_ensemble!, get_averages!, get_alphabeta, get_correlators
5759
export get_average_forces, get_classic_forces
5860
export pulse, sin_field, gaussian1, fake_dielectric_constant, read_charges_from_out!
5961
export integrate!
6062

61-
end
63+
end

src/dynamics.jl

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -96,9 +96,9 @@ function integrate!(
9696
# Update the ensemble
9797
index += 1
9898
t += settings.dt
99-
100-
# Evolution with f(t), k(t)
101-
step!(settings.algorithm, wigner, my_dt, tot_for, d2v_dr2, 1)
99+
100+
# Evolution with f(t), k(t)
101+
step!(settings.algorithm, wigner, my_dt, tot_for, d2v_dr2, 1)
102102

103103
# Classic integration (part 1)
104104
classic_evolution!(Rs, Ps, my_dt, tot_cl_for, 1)
@@ -135,7 +135,7 @@ function integrate!(
135135
tot_for = avg_for .+ ext_for
136136
tot_cl_for = cl_for .+ ext_for
137137

138-
# Evolution with f(t+dt), k(t+dt)
138+
# Evolution with f(t+dt), k(t+dt)
139139
step!(settings.algorithm, wigner, my_dt, tot_for, d2v_dr2, 2)
140140

141141
# Classic integration (part 2)

src/ensemble.jl

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -649,9 +649,15 @@ function get_λs(RR_corr::Matrix{T}) where {T<:AbstractFloat}
649649
return eigvals
650650
end
651651

652-
function equilibrium_ensemble(TEMPERATURE::T, file_dyn::String, ens_file::String, ndyn::Int, ens_bin::Int ) where {T<:AbstractFloat}
652+
function equilibrium_ensemble(
653+
TEMPERATURE::T,
654+
file_dyn::String,
655+
ens_file::String,
656+
ndyn::Int,
657+
ens_bin::Int,
658+
) where {T<:AbstractFloat}
653659

654-
PH = pyimport("cellconstructor.Phonons")
660+
PH = pyimport("cellconstructor.Phonons")
655661
PyEnsemble = pyimport("sscha.Ensemble")
656662
dyn = PH.Phonons(file_dyn, ndyn)
657663
py_ensemble = PyEnsemble.Ensemble(dyn, TEMPERATURE)

src/external_f.jl

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11

22
function read_charges_from_dict!(
3-
dict :: AbstractDict,
3+
dict::AbstractDict,
44
wigner::WignerDistribution{T},
55
) where {T<:AbstractFloat}
66
n_atoms = length(wigner.atoms)
@@ -14,7 +14,7 @@ function read_charges_from_dict!(
1414
end
1515

1616
function read_charges_from_out!(
17-
filename :: String,
17+
filename::String,
1818
wigner::WignerDistribution{T},
1919
) where {T<:AbstractFloat}
2020
n_atoms = length(wigner.atoms)
@@ -192,7 +192,7 @@ function gaussian1(A::T, w::T, t0::T) where {T<:AbstractFloat}
192192
# Amplitude in kV/cm
193193
# Frequency in THz
194194
# t_0 in fs
195-
195+
196196
A_Ry = A*CONV_EFIELD
197197
w_Ry = w*CONV_FREQ
198198
t0_Ry = t0/CONV_FS

src/phonons.jl

Lines changed: 17 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
11

22

3-
function get_alphabeta(TEMP :: T, w_full :: Vector{T}, pols_full :: Matrix{T}) where {T<:AbstractFloat}
3+
function get_alphabeta(
4+
TEMP::T,
5+
w_full::Vector{T},
6+
pols_full::Matrix{T},
7+
) where {T<:AbstractFloat}
48
# omega are frequencies in Rydberg
59
# T is in Kelvin
610

@@ -54,7 +58,11 @@ function get_alphabeta(TEMP :: T, w_full :: Vector{T}, pols_full :: Matrix{T}) w
5458
end
5559

5660

57-
function get_correlators(TEMP ::T , w_full :: Vector{T}, pols_full :: Matrix{T}) where {T<:AbstractFloat}
61+
function get_correlators(
62+
TEMP::T,
63+
w_full::Vector{T},
64+
pols_full::Matrix{T},
65+
) where {T<:AbstractFloat}
5866
# omega are frequencies in Rydberg
5967
# T is in Kelvin
6068

@@ -113,7 +121,7 @@ end
113121

114122
function extract_dynamical_matrix(
115123
wigner::WignerDistribution{T},
116-
TEMP :: T,
124+
TEMP::T,
117125
) where {T<:AbstractFloat}
118126

119127
function psi(w, TEMP, val)
@@ -142,7 +150,12 @@ end
142150

143151

144152

145-
function displace_along_mode!(mod :: Int32, eta :: T, wigner :: WignerDistribution, dyn) where {T<:AbstractFloat}
153+
function displace_along_mode!(
154+
mod::Int32,
155+
eta::T,
156+
wigner::WignerDistribution,
157+
dyn,
158+
) where {T<:AbstractFloat}
146159
# eta in Angstrom*sqrt(uma)
147160
eta = eta * CONV_BOHR * sqrt(CONV_MASS)
148161

@@ -152,8 +165,3 @@ function displace_along_mode!(mod :: Int32, eta :: T, wigner :: WignerDistributi
152165
du = v .* eta # No need to divide by sqrt(m), by definition of TDSCHA coord
153166
wigner.R_av .+= du
154167
end
155-
156-
157-
158-
159-

src/time_evolution.jl

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,14 @@ Arguments
1616
1717
It automatically calls the correct *_step! function.
1818
"""
19-
function step!(algorithm:: String, wigner:: WignerDistribution{T}, my_dt :: T, tot_for :: Vector{T}, d2v_dr2 :: Matrix{T}, part :: Int ) where {T <: AbstractFloat}
19+
function step!(
20+
algorithm::String,
21+
wigner::WignerDistribution{T},
22+
my_dt::T,
23+
tot_for::Vector{T},
24+
d2v_dr2::Matrix{T},
25+
part::Int,
26+
) where {T<:AbstractFloat}
2027

2128
if part == 1
2229
if "euler" == lowercase(algorithm)
@@ -30,7 +37,7 @@ function step!(algorithm:: String, wigner:: WignerDistribution{T}, my_dt :: T,
3037
elseif "generalized-verlet" == lowercase(algorithm)
3138
generalized_verlet_step!(wigner, my_dt, tot_for, d2v_dr2, 1)
3239
elseif "none" == lowercase(algorithm)
33-
nothing
40+
nothing
3441
else
3542
throw(ArgumentError("""
3643
Error, the selected algorithm $(algorithm)
@@ -45,7 +52,7 @@ function step!(algorithm:: String, wigner:: WignerDistribution{T}, my_dt :: T,
4552
elseif "generalized-verlet" == lowercase(algorithm)
4653
generalized_verlet_step!(wigner, my_dt, tot_for, d2v_dr2, 2)
4754
end
48-
end
55+
end
4956
end
5057

5158
"""
@@ -201,10 +208,10 @@ function generalized_verlet_step!(
201208
B1_ = copy(B0p)
202209
BLAS.syr2k!('U', 'T', -dt/2.0, d2V_dr2, C1, 1.0, B1_)
203210
LinearAlgebra.copytri!(B1_, 'U')
204-
211+
205212
err_B = norm((B1_ .- B1) .^ 2)
206213
err_C = norm((C1_ .- C1) .^ 2)
207-
err = err_B + err_C
214+
err = err_B + err_C
208215

209216
return B1_, C1_, err
210217

@@ -216,8 +223,8 @@ function generalized_verlet_step!(
216223
dthalf = dt / 2.0
217224
BLAS.gemm!('N', 'N', -dthalf, rho.RR_corr, d2V_dr2, 1.0, rho.RP_corr)
218225

219-
thr = 1e-12
220-
err = 1
226+
thr = 1e-12
227+
err = 1
221228
while err > thr
222229
B1, C1, err = obj(B1, C1, d2V_dr2, rho.PP_corr, rho.RP_corr)
223230
end

src/wigner.jl

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,4 +118,3 @@ function remove_translations(
118118
end
119119
return vectors[:, mask], values[mask]
120120
end
121-

0 commit comments

Comments
 (0)