Skip to content
Snippets Groups Projects
Commit 8e5b7d74 authored by Kostas Vilkelis's avatar Kostas Vilkelis :flamingo:
Browse files

example nb of current interface

parent 19c3b598
No related branches found
No related tags found
1 merge request!4Interface refactoring
This commit is part of merge request !4. Comments created here will be created in the context of that merge request.
%% 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
```
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