Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 8 additions & 3 deletions Modules/Minimizer.py
Original file line number Diff line number Diff line change
Expand Up @@ -224,6 +224,9 @@ def run_step(self, gradient, kl_new):
# Enlarge the step
if not self.fixed_step:
self.step *= self.increment_step

# Perform the minimization step for new direction
self.current_x = self.old_x - self.step * self.direction
else:
# Proceed with the line minimization

Expand All @@ -243,14 +246,16 @@ def run_step(self, gradient, kl_new):
print("Step too large (scalar = {} | kl_ratio = {}), reducing to {}".format(scalar, kl_ratio, self.step))
#print("Direction: ", self.direction)
#print("Gradient: ", gradient)

# Try again with reduced step
self.current_x = self.old_x - self.step * self.direction
else:
# The step is good, therefore next step perform a new direction
self.new_direction = True
if self.verbose:
print("Good step found with {}, try increment".format(self.step))

# Perform the minimiziation step
self.current_x = self.old_x - self.step * self.direction
# DO NOT update current_x - we accept the current position
# (current_x was already updated in the previous step)


def update_dyn(self, new_kl_ratio, dyn_gradient, structure_gradient = None):
Expand Down
4 changes: 2 additions & 2 deletions Modules/SchaMinimizer.py
Original file line number Diff line number Diff line change
Expand Up @@ -964,11 +964,11 @@ def print_info(self):
print (" supercell size = ", " ".join([str(x) for x in self.ensemble.supercell]))

# Get the current frequencies
w, pols = self.dyn.GenerateSupercellDyn(self.ensemble.supercell).DyagDinQ(0)
w, pols = self.dyn.DiagonalizeSupercell()#self.dyn.GenerateSupercellDyn(self.ensemble.supercell).DyagDinQ(0)
w *= __RyToCm__

# Get the starting frequencies
w0, p0 = self.ensemble.dyn_0.GenerateSupercellDyn(self.ensemble.supercell).DyagDinQ(0)
w0, p0 = self.ensemble.dyn_0.DiagonalizeSupercell()
w0 *= __RyToCm__

print ()
Expand Down
5 changes: 3 additions & 2 deletions Modules/fourier_gradient.jl
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ function get_gradient_fourier!(Φ_grad :: Array{Complex{T}, 3},
for i in 1:n_random
tmp = v_tilde[i, j, jq] * conj(δf_tilde[i, k, jq])
Φ_grad[j, k, jq] += tmp * weights[i]
Φ_grad_err[j, k, jq] += tmp * conj(tmp) * weights[i]
Φ_grad_err[j, k, jq] += abs2(tmp) * weights[i]

# @views mul!(tmp, v_tilde[:, jq, i], δf_tilde[:, jq, i]')
# @. tmp2 = tmp * conj(tmp)
Expand All @@ -103,9 +103,10 @@ function get_gradient_fourier!(Φ_grad :: Array{Complex{T}, 3},
begin
tmp_grad = zeros(Complex{T}, (3*nat, 3*nat, nq))
for iq in 1:nq
@views Φ_grad[:, :, iq] .+= Φ_grad[:, :, iq]'
@views tmp_grad[:, :, iq] .= Φ_grad[:, :, iq]
@views tmp_grad[:, :, iq] .+= Φ_grad[:, :, iq]'
end
Φ_grad .= tmp_grad
for iq in 1:nq
@views tmp_grad[:, :, iq] .+= conj.(Φ_grad[:, :, minus_q_index[iq]]')
end
Expand Down
2 changes: 1 addition & 1 deletion meson.build
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
project('python-sscha',
['c','fortran'],
version : '1.5.0',
version : '1.6.0',
license: 'GPL',
meson_version: '>= 1.1.0', # <- set min version of meson.
default_options : [
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ build-backend = "mesonpy"

[project]
name = "python-sscha"
version = "1.5.1"
version = "1.6.0"
description = "Python implementation of the sscha code"
authors = [{name = "Lorenzo Monacelli"}] # Put here email
readme = "README.md"
Expand Down
Loading