Skip to content
Snippets Groups Projects

Interface refactoring

Merged Kostas Vilkelis requested to merge interface-refactoring into main
All threads resolved!
1 file
+ 59
0
Compare changes
  • Side-by-side
  • Inline
+ 59
0
Antonio Manesco
Last comment by Johanna Zijderveld
%% Cell type:code id: tags:
``` python
import numpy as np
from codes import utils, model, solvers
```
%% Cell type:code id: tags:
``` python
def random_guess(vectors, int_model):
"""
Generate random guess.
Parameters:
-----------
vectors : list of tuples
Hopping vectors for the mean-field corrections.
"""
scale = 0.1*(1+np.max(np.abs([*int_model.values()])))
return utils.generate_guess(
vectors=vectors,
ndof=len([*int_model.values()][0]),
scale=scale
)
```
%% Cell type:code id: tags:
``` python
U0 = 1
nk = 100
filling = 2
hopp = np.kron(np.array([[0, 1], [0, 0]]), np.eye(2))
tb_model = {(0,): hopp + hopp.T.conj(), (1,): hopp, (-1,): hopp.T.conj()}
int_model = {
(0,): U0 * np.kron(np.eye(2), np.ones((2, 2))),
}
testModel = model.MfModel(tb_model, int_model, filling)
guess = utils.tb2grid(random_guess(tb_model.keys(), int_model), nk)
solvers.kspace_solver(testModel, guess)
```
%% Output
array([ 4.81536544e-01, 6.41071801e-03, -1.76048506e-07, ...,
0.00000000e+00, 1.33679796e-06, 0.00000000e+00])
%% Cell type:code id: tags:
``` python
```
%% Cell type:code id: tags:
``` python
```
Loading