mirror of
https://github.com/vale981/master-thesis
synced 2025-03-06 02:21:38 -05:00
remove obsolete files
This commit is contained in:
parent
96f10f4315
commit
f217e7c3ff
7 changed files with 0 additions and 2498 deletions
|
@ -1 +0,0 @@
|
|||
use flake
|
|
@ -1,64 +0,0 @@
|
|||
import matplotlib.pyplot as plt
|
||||
from hopsflow import gaussflow_two as gf
|
||||
import utilities as ut
|
||||
import hops.util.bcf
|
||||
import numpy as np
|
||||
|
||||
t_max = 40
|
||||
bcf_1 = hops.util.bcf.OhmicBCF_zeroTemp(
|
||||
1,
|
||||
1,
|
||||
1,
|
||||
)
|
||||
|
||||
bcf_2 = hops.util.bcf.OhmicBCF_zeroTemp(
|
||||
1,
|
||||
1,
|
||||
1,
|
||||
)
|
||||
|
||||
α_0_1 = gf.BCF(
|
||||
t_max,
|
||||
bcf_1,
|
||||
num_terms=4,
|
||||
resolution=0.01,
|
||||
)
|
||||
|
||||
α_1 = gf.BCF(
|
||||
t_max,
|
||||
hops.util.bcf.OhmicBCF_nonZeroTemp(s=1, eta=1, w_c=1, beta=1 / .8),
|
||||
num_terms=8,
|
||||
resolution=0.01,
|
||||
)
|
||||
|
||||
α_0_2 = gf.BCF(
|
||||
t_max,
|
||||
bcf_2,
|
||||
num_terms=4,
|
||||
resolution=0.01,
|
||||
)
|
||||
|
||||
params = gf.SystemParams(Ω=1, Λ=1, η=[1, 1], γ=0, α_0=[α_0_1, α_0_2])
|
||||
t_points = np.linspace(0, t_max, 500)
|
||||
|
||||
G = gf.Propagator(params)
|
||||
|
||||
initial_state = np.array([1,0,2,0])
|
||||
traj = G(t_points) @ initial_state
|
||||
with ut.hiro_style():
|
||||
plt.plot(t_points, traj[:, [0,2]])
|
||||
|
||||
C = gf.CorrelationMatrix(params,gf.initial_correlation_pure_osci(1 , 1), [α_1, None])
|
||||
|
||||
energy = C.system_energy(t_points)
|
||||
|
||||
with ut.hiro_style():
|
||||
plt.plot(t_points, energy)
|
||||
|
||||
flow = [C.flow(t_points, i) for i in range(2)]
|
||||
|
||||
with ut.hiro_style():
|
||||
plt.plot(t_points, flow[0])
|
||||
plt.plot(t_points, flow[1])
|
||||
|
||||
flow[0][-4]/flow[1][-4]
|
|
@ -1,219 +0,0 @@
|
|||
from types import ModuleType
|
||||
from typing import Callable, Tuple, Union, Iterator
|
||||
from lmfit import minimize, Parameters
|
||||
import matplotlib.pyplot as plt
|
||||
import matplotlib
|
||||
import numpy as np
|
||||
from numpy.polynomial import Polynomial
|
||||
from contextlib import contextmanager
|
||||
from pathlib import Path
|
||||
import h5py
|
||||
from hopsflow import hopsflow
|
||||
|
||||
|
||||
# def get_n_samples(config: ModuleType) -> int:
|
||||
# """Get the number of samples from ``stg``."""
|
||||
# with stg_helper.get_hierarchy_data(stg, read_only=True) as hd:
|
||||
# samp = hd.get_samples()
|
||||
# return samp if isinstance(samp, int) else 0
|
||||
|
||||
|
||||
# def has_all_samples(stg: ModuleType) -> bool:
|
||||
# return stg.__HI_number_of_samples == get_n_samples(stg)
|
||||
|
||||
|
||||
# def has_all_samples_checker(stg: ModuleType) -> Tuple[str, Callable[..., bool]]:
|
||||
# return "Has all samples?", lambda _: has_all_samples(stg)
|
||||
|
||||
|
||||
# def hopsflow_systemparams(stg: ModuleType):
|
||||
# system_params = stg_helper.get_system_param(stg)
|
||||
# return hopsflow.SystemParams(
|
||||
# system_params.L.todense(), stg.__g, stg.__w, stg.__bcf_scale, stg.__HI_nonlinear
|
||||
# )
|
||||
|
||||
|
||||
# def hopsflow_thermparams(stg: ModuleType, τ: np.ndarray):
|
||||
# ξ = stg_helper.get_eta_therm(stg)
|
||||
# ξ.calc_deriv = True
|
||||
|
||||
# return hopsflow.ThermalParams(
|
||||
# ξ=ξ,
|
||||
# τ=τ,
|
||||
# num_deriv=False,
|
||||
# rand_skip=stg.__HI_rand_skip if hasattr(stg, "__HI_rand_skip") else 0,
|
||||
# )
|
||||
|
||||
|
||||
def peruse_hierarchy_files(base: str) -> Iterator[h5py.File]:
|
||||
p = Path(base)
|
||||
for i in p.glob("*/*.h5"):
|
||||
f = h5py.File(i, "r")
|
||||
yield f
|
||||
f.close()
|
||||
|
||||
|
||||
def α_apprx(τ, g, w):
|
||||
return np.sum(
|
||||
g[np.newaxis, :] * np.exp(-w[np.newaxis, :] * (τ[:, np.newaxis])), axis=1
|
||||
)
|
||||
|
||||
|
||||
def fit_α(
|
||||
α: Callable[[np.ndarray], np.ndarray],
|
||||
n: int,
|
||||
t_max: float,
|
||||
support_points: Union[int, np.ndarray] = 1000,
|
||||
) -> Tuple[np.ndarray, np.ndarray]:
|
||||
"""
|
||||
Fit the BCF ``α`` to a sum of ``n`` exponentials up to
|
||||
``t_max`` using a number of ``support_points``.
|
||||
"""
|
||||
|
||||
def residual(fit_params, x, data):
|
||||
resid = 0
|
||||
w = np.array([fit_params[f"w{i}"] for i in range(n)]) + 1j * np.array(
|
||||
[fit_params[f"wi{i}"] for i in range(n)]
|
||||
)
|
||||
g = np.array([fit_params[f"g{i}"] for i in range(n)]) + 1j * np.array(
|
||||
[fit_params[f"gi{i}"] for i in range(n)]
|
||||
)
|
||||
resid = data - α_apprx(x, g, w)
|
||||
|
||||
return resid.view(float)
|
||||
|
||||
fit_params = Parameters()
|
||||
for i in range(n):
|
||||
fit_params.add(f"g{i}", value=0.1)
|
||||
fit_params.add(f"gi{i}", value=0.1)
|
||||
fit_params.add(f"w{i}", value=0.1)
|
||||
fit_params.add(f"wi{i}", value=0.1)
|
||||
|
||||
ts = np.asarray(support_points)
|
||||
if ts.size < 2:
|
||||
ts = np.linspace(0, t_max, support_points)
|
||||
|
||||
out = minimize(residual, fit_params, args=(ts, α(ts)))
|
||||
|
||||
w = np.array([out.params[f"w{i}"] for i in range(n)]) + 1j * np.array(
|
||||
[out.params[f"wi{i}"] for i in range(n)]
|
||||
)
|
||||
g = np.array([out.params[f"g{i}"] for i in range(n)]) + 1j * np.array(
|
||||
[out.params[f"gi{i}"] for i in range(n)]
|
||||
)
|
||||
|
||||
return w, g
|
||||
|
||||
|
||||
###############################################################################
|
||||
# Plot Porn #
|
||||
###############################################################################
|
||||
|
||||
|
||||
def wrap_plot(f):
|
||||
def wrapped(*args, ax=None, setup_function=plt.subplots, **kwargs):
|
||||
fig = None
|
||||
if not ax:
|
||||
fig, ax = setup_function()
|
||||
|
||||
ret_val = f(*args, ax=ax, **kwargs)
|
||||
return (fig, ax, ret_val) if ret_val else (fig, ax)
|
||||
|
||||
return wrapped
|
||||
|
||||
|
||||
@contextmanager
|
||||
def hiro_style():
|
||||
with plt.style.context("ggplot"):
|
||||
with matplotlib.rc_context(
|
||||
{
|
||||
# "font.family": "serif",
|
||||
"text.usetex": False,
|
||||
"pgf.rcfonts": False,
|
||||
"lines.linewidth": 1,
|
||||
}
|
||||
):
|
||||
yield True
|
||||
|
||||
|
||||
@wrap_plot
|
||||
def plot_complex(x, y, *args, ax=None, label="", **kwargs):
|
||||
label = label + ", " if (len(label) > 0) else ""
|
||||
ax.plot(x, y.real, *args, label=f"{label}real part", **kwargs)
|
||||
ax.plot(x, y.imag, *args, label=f"{label}imag part", **kwargs)
|
||||
ax.legend()
|
||||
|
||||
|
||||
@wrap_plot
|
||||
def plot_convergence(x, y, ax=None, label="", transform=lambda y: y, slice=None):
|
||||
label = label + ", " if (len(label) > 0) else ""
|
||||
slice = (0, -1) if not slice else slice
|
||||
for n, val, _ in y[slice[0] : slice[1]]:
|
||||
plt.plot(
|
||||
x, transform(val), label=f"{label}n={n}", alpha=n / y[-1][0], linestyle="--"
|
||||
)
|
||||
ax.errorbar(
|
||||
x,
|
||||
transform(y[-1][1]),
|
||||
yerr=y[-1][2],
|
||||
ecolor="yellow",
|
||||
label=f"{label}n={y[-1][0]}",
|
||||
color="red",
|
||||
)
|
||||
|
||||
return None
|
||||
|
||||
|
||||
@wrap_plot
|
||||
def plot_diff_vs_sigma(
|
||||
x,
|
||||
y,
|
||||
reference,
|
||||
ax=None,
|
||||
label="",
|
||||
transform=lambda y: y,
|
||||
ecolor="yellow",
|
||||
):
|
||||
label = label + ", " if (len(label) > 0) else ""
|
||||
ax.fill_between(
|
||||
x,
|
||||
0,
|
||||
y[-1][2],
|
||||
color=ecolor,
|
||||
label=fr"{label}$\sigma$",
|
||||
)
|
||||
|
||||
for n, val, _ in y:
|
||||
diff = np.abs(transform(val) - reference)
|
||||
within = (diff < y[-1][2]).sum() / y[-1][2].size
|
||||
ax.plot(
|
||||
x,
|
||||
diff,
|
||||
label=fr"{label}n={n} $\Delta<\sigma = {within * 100}\%$",
|
||||
alpha=n / y[-1][0],
|
||||
)
|
||||
|
||||
|
||||
###############################################################################
|
||||
# Numpy Hacks #
|
||||
###############################################################################
|
||||
|
||||
|
||||
def e_i(i: int, size: int) -> np.ndarray:
|
||||
r"""Cartesian base vector :math:`e_i`."""
|
||||
|
||||
vec = np.zeros(size)
|
||||
vec[i] = 1
|
||||
return vec
|
||||
|
||||
|
||||
def except_element(array: np.ndarray, index: int) -> np.ndarray:
|
||||
mask = [i != index for i in range(array.size)]
|
||||
return array[mask]
|
||||
|
||||
|
||||
def poly_real(p: Polynomial) -> Polynomial:
|
||||
"""Return the real part of ``p``."""
|
||||
new = p.copy()
|
||||
new.coef = p.coef.real
|
||||
return new
|
126
python/flake.lock
generated
126
python/flake.lock
generated
|
@ -1,126 +0,0 @@
|
|||
{
|
||||
"nodes": {
|
||||
"flake-utils": {
|
||||
"locked": {
|
||||
"lastModified": 1638122382,
|
||||
"narHash": "sha256-sQzZzAbvKEqN9s0bzWuYmRaA03v40gaJ4+iL1LXjaeI=",
|
||||
"owner": "numtide",
|
||||
"repo": "flake-utils",
|
||||
"rev": "74f7e4319258e287b0f9cb95426c9853b282730b",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"owner": "numtide",
|
||||
"repo": "flake-utils",
|
||||
"type": "github"
|
||||
}
|
||||
},
|
||||
"flake-utils_2": {
|
||||
"locked": {
|
||||
"lastModified": 1610051610,
|
||||
"narHash": "sha256-U9rPz/usA1/Aohhk7Cmc2gBrEEKRzcW4nwPWMPwja4Y=",
|
||||
"owner": "numtide",
|
||||
"repo": "flake-utils",
|
||||
"rev": "3982c9903e93927c2164caa727cd3f6a0e6d14cc",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"owner": "numtide",
|
||||
"repo": "flake-utils",
|
||||
"type": "github"
|
||||
}
|
||||
},
|
||||
"nixpkgs": {
|
||||
"locked": {
|
||||
"lastModified": 1638806821,
|
||||
"narHash": "sha256-v2qd2Bsmzft53s43eCbN+4ocrLksRdFLyF/MAGuWuDA=",
|
||||
"owner": "NixOS",
|
||||
"repo": "nixpkgs",
|
||||
"rev": "bc5d68306b40b8522ffb69ba6cff91898c2fbbff",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"id": "nixpkgs",
|
||||
"ref": "nixos-unstable",
|
||||
"type": "indirect"
|
||||
}
|
||||
},
|
||||
"nixpkgs_2": {
|
||||
"locked": {
|
||||
"lastModified": 1638806821,
|
||||
"narHash": "sha256-v2qd2Bsmzft53s43eCbN+4ocrLksRdFLyF/MAGuWuDA=",
|
||||
"owner": "NixOS",
|
||||
"repo": "nixpkgs",
|
||||
"rev": "bc5d68306b40b8522ffb69ba6cff91898c2fbbff",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"id": "nixpkgs",
|
||||
"ref": "nixos-unstable",
|
||||
"type": "indirect"
|
||||
}
|
||||
},
|
||||
"nixpkgs_3": {
|
||||
"locked": {
|
||||
"lastModified": 1610729867,
|
||||
"narHash": "sha256-bk/SBaBLqZX/PEqal27DMQwAHHl0dcZMp8NNksQr80s=",
|
||||
"owner": "NixOS",
|
||||
"repo": "nixpkgs",
|
||||
"rev": "04af07c659c6723a2259bb6bc00a47ec53330f20",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"owner": "NixOS",
|
||||
"repo": "nixpkgs",
|
||||
"type": "github"
|
||||
}
|
||||
},
|
||||
"poetry2nix": {
|
||||
"inputs": {
|
||||
"flake-utils": "flake-utils_2",
|
||||
"nixpkgs": "nixpkgs_3"
|
||||
},
|
||||
"locked": {
|
||||
"lastModified": 1638854297,
|
||||
"narHash": "sha256-mt5gMwAThp8FpcvRsKhs/y/VxLDNgH4MJJLlFbbs4gk=",
|
||||
"owner": "nix-community",
|
||||
"repo": "poetry2nix",
|
||||
"rev": "a4b769203284c91529480adcbb4f17f04d3ff67b",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"owner": "nix-community",
|
||||
"repo": "poetry2nix",
|
||||
"type": "github"
|
||||
}
|
||||
},
|
||||
"root": {
|
||||
"inputs": {
|
||||
"nixpkgs": "nixpkgs",
|
||||
"utils": "utils"
|
||||
}
|
||||
},
|
||||
"utils": {
|
||||
"inputs": {
|
||||
"flake-utils": "flake-utils",
|
||||
"nixpkgs": "nixpkgs_2",
|
||||
"poetry2nix": "poetry2nix"
|
||||
},
|
||||
"locked": {
|
||||
"lastModified": 1639060819,
|
||||
"narHash": "sha256-cf6Y23NnI0C7UUlM0mcf8SZUUlbSdPFFkJJvNq1Zf2A=",
|
||||
"owner": "vale981",
|
||||
"repo": "hiro-flake-utils",
|
||||
"rev": "e6ee28774a9eab35859c17f1c7a590afa385b7a2",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"owner": "vale981",
|
||||
"repo": "hiro-flake-utils",
|
||||
"type": "github"
|
||||
}
|
||||
}
|
||||
},
|
||||
"root": "root",
|
||||
"version": 7
|
||||
}
|
|
@ -1,27 +0,0 @@
|
|||
{
|
||||
description = "Calculating open system bath energy changes with HOPS and analytically.";
|
||||
|
||||
|
||||
inputs = {
|
||||
nixpkgs.url = "nixpkgs/nixos-unstable";
|
||||
utils.url = "github:vale981/hiro-flake-utils";
|
||||
};
|
||||
|
||||
outputs = { self, utils, nixpkgs, ... }:
|
||||
(utils.lib.poetry2nixWrapper nixpkgs {
|
||||
name = "master";
|
||||
#noPackage = true;
|
||||
shellPackages = pkgs: with pkgs; [ black pyright sshfs sage python3Packages.jupyter python3Packages.numba ];
|
||||
shellOverride = (oldAttrs: {
|
||||
# shellHook = ''
|
||||
# echo "HI"
|
||||
# export PYTHONPATH=$PYTHONPATH:$(realpath ./energy_flow_proper)
|
||||
# '';
|
||||
});
|
||||
|
||||
|
||||
poetryArgs = {
|
||||
projectDir = ./.;
|
||||
};
|
||||
});
|
||||
}
|
2033
python/poetry.lock
generated
2033
python/poetry.lock
generated
File diff suppressed because it is too large
Load diff
|
@ -1,28 +0,0 @@
|
|||
[tool.poetry]
|
||||
name = "hiro_master_python"
|
||||
version = "1.0"
|
||||
description = "Calculating open system bath energy changes with HOPS and analytically."
|
||||
authors = ["Valentin Boettcher <hiro at protagon.space>"]
|
||||
license = "MIT"
|
||||
|
||||
[tool.poetry.dependencies]
|
||||
python = ">=3.9,<3.11"
|
||||
sqlitedict = "^1.7.0"
|
||||
numpy = "^1.21.4"
|
||||
scipy = "^1.7.3"
|
||||
stocproc = { git = "https://github.com/vale981/stocproc" }
|
||||
fcSpline = { git = "https://github.com/vale981/fcSpline" }
|
||||
hopsflow = {git = "https://github.com/vale981/hopsflow", rev = "main"}
|
||||
hops = {git = "git@gitlab.hrz.tu-chemnitz.de:s4498638--tu-dresden.de/hops.git", rev = "main"}
|
||||
tqdm = "^4.62.3"
|
||||
lmfit = "^1.0.3"
|
||||
matplotlib = "^3.5.0"
|
||||
jupyter = "^1.0.0"
|
||||
qutip = "^4.6.2"
|
||||
cache-decorator = {extras = ["numpy"], version = "^2.0.12"}
|
||||
|
||||
[tool.poetry.dev-dependencies]
|
||||
|
||||
[build-system]
|
||||
requires = ["poetry>=0.12"]
|
||||
build-backend = "poetry.core.masonry.api"
|
Loading…
Add table
Reference in a new issue