Skip to content

Commit

Permalink
kink correlation function
Browse files Browse the repository at this point in the history
  • Loading branch information
amartyabose committed Dec 17, 2024
1 parent 2891ac3 commit b2ff4e3
Show file tree
Hide file tree
Showing 7 changed files with 52 additions and 400,054 deletions.
200,000 changes: 0 additions & 200,000 deletions examples/04-Trimer-Cavity/quantum_dynamics_lab_rotation/monomer_cav/spectral_density

This file was deleted.

12 changes: 0 additions & 12 deletions examples/04-Trimer-Cavity/simulate.toml

This file was deleted.

200,000 changes: 0 additions & 200,000 deletions examples/04-Trimer-Cavity/spectral_density

This file was deleted.

19 changes: 0 additions & 19 deletions examples/04-Trimer-Cavity/system.toml

This file was deleted.

Binary file removed examples/04-Trimer-Cavity/test.hdf5
Binary file not shown.
61 changes: 48 additions & 13 deletions src/Equilibrium.jl
Original file line number Diff line number Diff line change
Expand Up @@ -140,26 +140,61 @@ function complex_time_correlation_function(::QDSimUtilities.Method"QuAPI", units
Utilities.check_or_insert_value(data, "eqm_rho", real.(At / tr(At)))
A = ParseInput.parse_operator(sim_node["A"], sys.Hamiltonian)
B = ParseInput.parse_operator(sim_node["B"], sys.Hamiltonian)
ofile = sim_node["correlation_function_output"]
ts, corr, _ = ComplexQuAPI.complex_correlation_function(; Hamiltonian=sys.Hamiltonian, β=bath.β, tfinal, dt=sim.dt, N=sim.nsteps, Jw=bath.Jw, svec=bath.svecs, A, B=[B], Z, verbose=true, extraargs, output=data, type_corr)
open("real_corr_$(ofile)", "w") do io
writedlm(io, [ts./units.time_unit real.(corr)])
end
open("imag_corr_$(ofile)", "w") do io
writedlm(io, [ts./units.time_unit imag.(corr)])
ft = get(sim_node, "fourier_transform", false)
if ft
conjugated = get(sim_node, "conjugate", false)
ωs, spectrum = conjugated ? Utilities.fourier_transform(ts, conj.(corr)) : Utilities.fourier_transform(ts, corr)
Utilities.check_or_insert_value(data, "frequency", ωs ./ units.energy_unit)
Utilities.check_or_insert_value(data, "spectrum", spectrum)
end
end
data
end

function complex_time_correlation_function(::QDSimUtilities.Method"adaptive-kinks-QuAPI", units::QDSimUtilities.Units, sys::QDSimUtilities.System, bath::QDSimUtilities.Bath, sim::QDSimUtilities.Simulation, dat_group::HDF5.Group, sim_node; dry=false)
if !dry
@info "Running a complex time QuAPI simulation. Please cite:"
QDSimUtilities.print_citation(ComplexTNPI.references)
end
cutoff = get(sim_node, "cutoff", 1e-10)
tfinal = sim_node["tfinal"] * units.time_unit
exec = get(sim_node, "exec", "ThreadedEx")
if exec != "SequentialEx"
@info "Running with $(Threads.nthreads()) threads."
end

type_corr = get(sim_node, "corr_type", "symm")

cutoff_group = Utilities.create_and_select_group(dat_group, "cutoff=$(cutoff)")
prop_cutoff = get(sim_node, "propagator_cutoff", 0.0)
data = Utilities.create_and_select_group(cutoff_group, "prop_cutoff=$(prop_cutoff)")
if !dry
Utilities.check_or_insert_value(data, "dt", sim.dt / units.time_unit)
Utilities.check_or_insert_value(data, "time_unit", units.time_unit)
Utilities.check_or_insert_value(data, "time", 0:sim.dt/units.time_unit:tfinal/units.time_unit |> collect)
flush(data)
extraargs = QuAPI.QuAPIArgs(; cutoff, prop_cutoff)

nsites = size(sys.Hamiltonian, 1)

idmat = Matrix(1.0I, nsites, nsites)
@info "Calculating the partition function for normalization."
At, _ = ComplexQuAPI.adaptive_kink_A_of_t(; Hamiltonian=sys.Hamiltonian, β=bath.β, t=0.0, N=sim.nsteps, Jw=bath.Jw, svec=bath.svecs, A=idmat, extraargs)
norm_op = get(sim_node, "partition_function", "id")
Z = real(tr(At * ParseInput.parse_operator(norm_op, sys.Hamiltonian)))
@info "Partition function = $(Z)."
@info "Saving the equilibrium density matrix."
Utilities.check_or_insert_value(data, "eqm_rho", real.(At / tr(At)))
A = ParseInput.parse_operator(sim_node["A"], sys.Hamiltonian)
B = ParseInput.parse_operator(sim_node["B"], sys.Hamiltonian)
ts, corr, _ = ComplexQuAPI.adaptive_kink_complex_correlation_function(; Hamiltonian=sys.Hamiltonian, β=bath.β, tfinal, dt=sim.dt, N=sim.nsteps, Jw=bath.Jw, svec=bath.svecs, A, B=[B], Z, verbose=true, extraargs, output=data, type_corr)
ft = get(sim_node, "fourier_transform", false)
if ft
conjugated = get(sim_node, "conjugate", false)
ωs, spectrum = conjugated ? Utilities.fourier_transform(ts, conj.(corr)) : Utilities.fourier_transform(ts, corr)
Utilities.check_or_insert_value(data, "frequency", ωs ./units.energy_unit)
Utilities.check_or_insert_value(data, "frequency", ωs ./ units.energy_unit)
Utilities.check_or_insert_value(data, "spectrum", spectrum)
open("real_spect_$(ofile)", "w") do io
writedlm(io, [ωs./units.energy_unit real.(spectrum)])
end
open("imag_spect_$(ofile)", "w") do io
writedlm(io, [ωs./units.energy_unit imag.(spectrum)])
end
end
end
data
Expand Down
14 changes: 4 additions & 10 deletions src/Post.jl
Original file line number Diff line number Diff line change
Expand Up @@ -105,22 +105,16 @@ function calculate_print_observable(::QDSimUtilities.Calculation"complex_corr",
ts = read_dataset(data_node, "time")
corr = read_dataset(data_node, "corr")

open("$(fname)_real$(ext)", "w") do io
writedlm(io, [round.(ts; sigdigits=10) round.(real.(corr); sigdigits=10)])
end
open("$(fname)_imag$(ext)", "w") do io
writedlm(io, [round.(ts; sigdigits=10) round.(imag.(corr); sigdigits=10)])
open("$(fname)$(ext)", "w") do io
writedlm(io, [round.(ts; sigdigits=10) round.(real.(corr); sigdigits=10) round.(imag.(corr); sigdigits=10)])
end

ft = get(sim_node, "fourier_transform", false)
if ft
freq = read_dataset(data_node, "frequency")
spect = read_dataset(data_node, "spectrum")
open("$(fname)_real_spectrum$(ext)", "w") do io
writedlm(io, [round.(freq; sigdigits=10) round.(real.(spect); sigdigits=10)])
end
open("$(fname)_imag_spectrum$(ext)", "w") do io
writedlm(io, [round.(freq; sigdigits=10) round.(imag.(spect); sigdigits=10)])
open("$(fname)_spectrum$(ext)", "w") do io
writedlm(io, [round.(freq; sigdigits=10) round.(real.(spect); sigdigits=10) round.(imag.(spect); sigdigits=10)])
end
end
end
Expand Down

2 comments on commit b2ff4e3

@amartyabose
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@JuliaRegistrator
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Registration pull request created: JuliaRegistries/General/121554

Tip: Release Notes

Did you know you can add release notes too? Just add markdown formatted text underneath the comment after the text
"Release notes:" and it will be added to the registry PR, and if TagBot is installed it will also be added to the
release that TagBot creates. i.e.

@JuliaRegistrator register

Release notes:

## Breaking changes

- blah

To add them here just re-invoke and the PR will be updated.

Tagging

After the above pull request is merged, it is recommended that a tag is created on this repository for the registered package version.

This will be done automatically if the Julia TagBot GitHub Action is installed, or can be done manually through the github interface, or via:

git tag -a v0.1.0 -m "<description of version>" b2ff4e3eec70b5b11bc5527057df9a5f5f0c77ef
git push origin v0.1.0

Please sign in to comment.