Skip to content
Snippets Groups Projects
Commit 6d3bf614 authored by Antonio Manesco's avatar Antonio Manesco
Browse files

prototype for total energy solver

parent 7a09e384
No related branches found
No related tags found
1 merge request!3create solvers and interface modules
import numpy as np
from . import utils
from .hf import updated_matrices
from .hf import updated_matrices, total_energy
from functools import partial
def optimize(mf, cost_function, optimizer, optimizer_kwargs):
......@@ -78,6 +78,14 @@ def kspace_cost(mf, model):
delta_mf = model.mf_k - mf
return utils.complex_to_real(utils.matrix_to_flat(delta_mf))
def kspace_totalenergy_cost(mf, model):
mf = utils.flat_to_matrix(utils.real_to_complex(mf), model.mf_k.shape)
model.rho, model.mf_k = updated_matrices(mf_k=mf, model=model)
return total_energy(
model.hamiltonians_0 + model.mf_k,
model.rho,
)
def kspace_solver(model, optimizer, cost_function, optimizer_kwargs):
"""
k-space solver.
......@@ -95,4 +103,4 @@ def kspace_solver(model, optimizer, cost_function, optimizer_kwargs):
initial_mf = model.mf_k
initial_mf = utils.complex_to_real(utils.matrix_to_flat(initial_mf))
partial_cost = partial(cost_function, model=model)
optimize(initial_mf, partial_cost, optimizer, optimizer_kwargs)
\ No newline at end of file
optimize(initial_mf, partial_cost, optimizer, optimizer_kwargs)
Source diff could not be displayed: it is too large. Options to address this: view the blob.
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment