Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
M
MeanFi
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Quantum Tinkerer
MeanFi
Commits
8e5b7d74
Commit
8e5b7d74
authored
Feb 23, 2024
by
Kostas Vilkelis
Browse files
Options
Downloads
Patches
Plain Diff
example nb of current interface
parent
19c3b598
Branches
Branches containing commit
Tags
Tags containing commit
1 merge request
!4
Interface refactoring
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
examples/testInterface.ipynb
+105
-0
105 additions, 0 deletions
examples/testInterface.ipynb
with
105 additions
and
0 deletions
examples/testInterface.ipynb
0 → 100644
+
105
−
0
View file @
8e5b7d74
{
"cells": [
{
"cell_type": "code",
"execution_count": 1,
"metadata": {},
"outputs": [],
"source": [
"import numpy as np\n",
"from codes import utils, model, solvers"
]
},
{
"cell_type": "code",
"execution_count": 2,
"metadata": {},
"outputs": [],
"source": [
"def random_guess(vectors, int_model):\n",
" \"\"\"\n",
" Generate random guess.\n",
"\n",
" Parameters:\n",
" -----------\n",
" vectors : list of tuples\n",
" Hopping vectors for the mean-field corrections.\n",
" \"\"\"\n",
" scale = 0.1*(1+np.max(np.abs([*int_model.values()])))\n",
" return utils.generate_guess(\n",
" vectors=vectors,\n",
" ndof=len([*int_model.values()][0]),\n",
" scale=scale\n",
" )"
]
},
{
"cell_type": "code",
"execution_count": 3,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"array([ 4.81536544e-01, 6.41071801e-03, -1.76048506e-07, ...,\n",
" 0.00000000e+00, 1.33679796e-06, 0.00000000e+00])"
]
},
"execution_count": 3,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"U0 = 1\n",
"nk = 100\n",
"filling = 2\n",
"\n",
"hopp = np.kron(np.array([[0, 1], [0, 0]]), np.eye(2))\n",
"tb_model = {(0,): hopp + hopp.T.conj(), (1,): hopp, (-1,): hopp.T.conj()}\n",
"int_model = {\n",
" (0,): U0 * np.kron(np.eye(2), np.ones((2, 2))),\n",
"}\n",
"\n",
"testModel = model.MfModel(tb_model, int_model, filling)\n",
"guess = utils.tb2grid(random_guess(tb_model.keys(), int_model), nk)\n",
"solvers.kspace_solver(testModel, guess)"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
}
],
"metadata": {
"kernelspec": {
"display_name": "base",
"language": "python",
"name": "python3"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.11.7"
}
},
"nbformat": 4,
"nbformat_minor": 2
}
%% 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
```
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment