Skip to content

Commit

Permalink
Sync temperature in hybridization and current steps
Browse files Browse the repository at this point in the history
  • Loading branch information
edan-bainglass committed Feb 18, 2024
1 parent 0e506aa commit 7d584ee
Show file tree
Hide file tree
Showing 6 changed files with 47 additions and 17 deletions.
2 changes: 1 addition & 1 deletion examples/coulomb_blockade/pentacene/curr.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ def compute_current(
V_min=-2.5,
V_max=2.5,
dV=0.1,
temperature=9,
temperature=300.0,
transmission_folder_path="transmission_folder",
) -> None:
"""docstring"""
Expand Down
13 changes: 8 additions & 5 deletions examples/coulomb_blockade/pentacene/hybr.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
from pathlib import Path

import numpy as np
from ase.units import kB
from qtpyt.block_tridiag import greenfunction
from qtpyt.continued_fraction import get_ao_charge
from qtpyt.hybridization import Hybridization
Expand All @@ -21,13 +22,13 @@ def hybridize_orbitals(
hs_list_ii,
hs_list_ij,
self_energies,
temperature=300.0,
solver="dyson",
eta=1e-4,
E_min=-3.0,
E_max=3.0,
E_step=1e-2,
E_grid_size=3000,
beta=70.0,
matsubara_grid_scalar=1.0,
) -> None:
"""docstring"""

Expand Down Expand Up @@ -70,8 +71,10 @@ def hybridize_orbitals(

# Matsubara
gf.eta = 0.0
energies = 1.0j * (2 * np.arange(E_grid_size) + 1) * np.pi / beta
gd = GridDesc(energies, no, complex)
beta = 1 / (kB * temperature)
E_grid_size = len(energies) * matsubara_grid_scalar
matsubara_energies = 1.0j * (2 * np.arange(E_grid_size) + 1) * np.pi / beta
gd = GridDesc(matsubara_energies, no, complex)
HB = gd.empty_aligned_orbs()

for e, energy in enumerate(gd.energies):
Expand All @@ -81,7 +84,7 @@ def hybridize_orbitals(

if comm.rank == 0:
np.save(output_dir / "occupancies.npy", get_ao_charge(gfp))
np.save(output_dir / "matsubara_energies.npy", energies)
np.save(output_dir / "matsubara_energies.npy", matsubara_energies)


if __name__ == "__main__":
Expand Down
10 changes: 3 additions & 7 deletions examples/coulomb_blockade/tester.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -262,16 +262,13 @@
" # \"E_min\": -3.0,\n",
" # \"E_max\": 3.0,\n",
" # \"E_step\": 1e-2,\n",
" # \"matsubara_grid_scalar\": 1.0,\n",
" # }\n",
" # ),\n",
" \"hybridization\": {\n",
" \"code\": orm.load_code(\"hybr-script\"),\n",
" # \"parameters\": orm.Dict(\n",
" # {\n",
" # \"E_grid_size\": 3000,\n",
" # \"beta\": 70.0,\n",
" # }\n",
" # ),\n",
" \"temperature\": orm.Float(300.0),\n",
" \"matsubara_grid_scalar\": orm.Float(1.0),\n",
" \"metadata\": metadata,\n",
" },\n",
" \"dmft\": {\n",
Expand Down Expand Up @@ -309,7 +306,6 @@
" # \"V_min\": -2.5,\n",
" # \"V_max\": 2.5,\n",
" # \"dV\": 0.1,\n",
" # \"temperature\": 9,\n",
" # }),\n",
" },\n",
"}"
Expand Down
14 changes: 12 additions & 2 deletions src/aiida_quantum_transport/calculations/current.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,13 @@ def define(cls, spec: CalcJobProcessSpec) -> None:
help="The current script",
)

spec.input(
"temperature",
valid_type=orm.Float,
default=lambda: orm.Float(300.0),
help="The temperature in Kelvin",
)

spec.input(
"parameters",
valid_type=orm.Dict,
Expand Down Expand Up @@ -83,8 +90,11 @@ def prepare_for_submission(self, folder: Folder) -> CalcInfo:

parameters_filename = "parameters.pkl"
with open(temp_input_dir / parameters_filename, "wb") as file:
parameters: orm.Dict = self.inputs.parameters
pickle.dump(parameters.get_dict(), file)
parameters = {
**self.inputs.parameters.get_dict(),
"temperature": self.inputs.temperature.value,
}
pickle.dump(parameters, file)

precomputed_input_dir = input_dir / "precomputed"
(temp_dir / precomputed_input_dir).mkdir()
Expand Down
16 changes: 16 additions & 0 deletions src/aiida_quantum_transport/calculations/hybridize.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,20 @@ def define(cls, spec: CalcJobProcessSpec) -> None:
help="The results folder of the greens function parameters calculation",
)

spec.input(
"temperature",
valid_type=orm.Float,
default=lambda: orm.Float(300.0),
help="The temperature in Kelvin",
)

spec.input(
"matsubara_grid_scalar",
valid_type=orm.Float,
default=lambda: orm.Float(1.0),
help="The scalar used to modify the matsubara energy grid",
)

spec.input(
"greens_function_parameters",
valid_type=orm.Dict,
Expand Down Expand Up @@ -131,6 +145,8 @@ def prepare_for_submission(self, folder: Folder) -> CalcInfo:
**self.inputs.greens_function_parameters,
**self.inputs.energy_grid_parameters,
**self.inputs.parameters,
"temperature": self.inputs.temperature.value,
"matsubara_grid_scalar": self.inputs.matsubara_grid_scalar.value,
}
pickle.dump(parameters, file)

Expand Down
9 changes: 7 additions & 2 deletions src/aiida_quantum_transport/workchains/coulomb_diamonds.py
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,12 @@ def define(cls, spec: WorkChainSpec) -> None:
spec.expose_inputs(
HybridizationCalculation,
namespace="hybridization",
include=["code", "parameters", "metadata"],
include=[
"code",
"temperature",
"matsubara_grid_scalar",
"metadata",
],
)

spec.expose_inputs(
Expand Down Expand Up @@ -275,7 +280,6 @@ def compute_hybridization(self):
},
"greens_function_parameters": self.inputs.greens_function_parameters,
"energy_grid_parameters": self.inputs.energy_grid_parameters,
"parameters": self.inputs.hybridization.parameters,
**self.exposed_inputs(
HybridizationCalculation,
namespace="hybridization",
Expand Down Expand Up @@ -385,6 +389,7 @@ def compute_current(self):
"transmission": {
"remote_results_folder": self.ctx.transmission.outputs.remote_results_folder,
},
"temperature": self.inputs.hybridization.temperature,
**self.exposed_inputs(
CurrentCalculation,
namespace="current",
Expand Down

0 comments on commit 7d584ee

Please sign in to comment.