Skip to content

Commit

Permalink
Merge pull request #4 from spalato/feature-jlv10
Browse files Browse the repository at this point in the history
Upgraded to julia v1.10
  • Loading branch information
spalato authored Oct 4, 2024
2 parents 6cb89e4 + 3d42c31 commit 9861ace
Show file tree
Hide file tree
Showing 66 changed files with 2,868 additions and 2,651 deletions.
4 changes: 2 additions & 2 deletions Project.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name = "Mbo"
uuid = "abb35812-7e48-465d-8fd2-5263f57cc2e0"
authors = ["Samuel Palato <>"]
version = "0.1.0"
authors = ["Samuel Palato"]
version = "1.1.0"

[deps]
DSP = "717857b8-e6f2-59f4-9121-6e50c889abd2"
Expand Down
35 changes: 23 additions & 12 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ Mbo.jl - Multimode Brownian Oscillator

Semiclassical modeling of non-linear spectra in the time domain using the
Multimode Brownian Oscillator model. Designed for the modeling of 2D
visible spectra. Hopefully fast, hopefully easy to use.
visible spectra. Hopefully fast.

Description
-----------
Expand All @@ -20,12 +20,16 @@ For example:
# build a system. It's still a bit tedious, but that's where the thinking happens.
using Mbo
s = System("g") # use "g" as a ground state
# Set energy and transition dipole moment
energy!(s, "e", ev2angphz(1.5)) # use angular PHz
# Add a state of energy of state "e" is 1.5 eV, which we need to convert
# to angular PHz
energy!(s, "e", ev2angphz(1.5))
# Set transition dipole moment of the g->e transition
dipole!(s, "g", "e", 1.0)

# Define a lineshape functions (some common cases are supplied).
# Define a lineshape functions. Here, 0.02 t + (0.02 t)^2/2
# Most common cases are supplied.
ls(t) = ev2angphz(0.02)*t + 0.5*(ev2angphz(0.02)*t)^2
# Set the function `ls(t)` as the lineshape for the e-e response.
lineshape!(s, "e", "e", ls)

# calculation grid, in fs. tedious bookkeeping done by the code.
Expand Down Expand Up @@ -61,8 +65,7 @@ You'll need it, but it is easy to install.
`Matlab` or `python` while providing performance typical of compiled languages
such as `Fortran` or `C`. Hopefully, the language is easy to pick up for anyone
familiar with any of these. Julia is available for Windows, Mac, Linux. Get it
from [here](https://julialang.org/downloads/) (v0.7 or later untested. Please
tell me if it breaks!)
from [here](https://julialang.org/downloads/).

Once julia is installed, open `julia` and type:

Expand All @@ -85,6 +88,11 @@ Finally precompile the package with
Mbo.jl pkg> precompile
```

The initial version of this code (up to `Mbo.jl v1.0`) was written for
`julia v0.6`, which was never intended for long-term support. The current
version of `Mbo.jl` has been updated to work with `julia v1.10`. For upgrading
your scripts, see the [migration guide](migration_guide.md).

Documentation
============
The main element of this package is the `System` object, which contains all the
Expand All @@ -106,7 +114,7 @@ When multiple states are involved, different transition dipole operators can be
involved in the third order response, and thus in the 4-point correlation
function. A given combination of 4 transition dipole operator
take the system through up to 4 spectroscopically coupled states. The path the
system takes through it's manifold of states is called here a Hilbert Path.
system takes through its manifold of states is called here a Hilbert Path.
As previously mentionned, each of these Hilbert paths gives rise to 4
double-sided Feynmann diagrams.

Expand Down Expand Up @@ -134,17 +142,20 @@ modify the `System` object end with `!` (this is purely a `julia` convention,
`!` has no special meaning). States are indexed by case-sensitive strings.
You can use "G", "X1", "S+3/2L", as you wish.

Setting and reading state energies and transition dipoles are rather
straightforward. No implicit unit conversions are made.
Setting and reading state energies and transition dipoles is rather
straightforward. No implicit unit conversions are made, it's up to the user
to ensure the proper units are supplied. The code expects energies
to be supplied as angular frequencies, inverse of your time units. If you use a
time grid in fs, you should supply energies in angular PHz.
```julia
using Mbo
# use "g" as a ground state with energy 0
s = System("g")
@assert "g" in states(s) # use the @assert macro for simple tests
@assert energy(s, "g") == 0
# set energies in angular frequencies, inverse of your time axis (PHz for fs)
energy!(s, "x1", 1.2)
energy!(s, "x2", 1.4)
energy!(s, "x1", 1.2) # x1 has ω = 1.2 ang PHz
energy!(s, "x2", 1.4) # x2 has ω = 1.4 ang PHz
# read energies:
@assert energy(s, "x2")-energy(s, "x1") == 1.4-1.2
@assert length(states(s)) == 3
Expand Down Expand Up @@ -270,7 +281,7 @@ can't achieve what you want? Lost and confused? Anything works.
TODO
====
- [x] Handle ground states easily. (Default lineshape functions in case they're missing)
- [ ] Compilation to LUT
- [x] Compilation to LUT
- [ ] Add rotating frames properly.
- [ ] Add automatic rephasing vs non-rephasing (`rephasing(grid,system)`).
- [ ] Convenience for zeroing transition dipole moments (`forbidden`?)
Expand Down
17 changes: 10 additions & 7 deletions examples/aimd_full/linear_xcf.jl
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,11 @@ import YAML
using Mbo
using ProgressMeter
import DSP: fftfreq
using Printf
using FFTW
using DelimitedFiles

tag(i) = @sprintf "X%02d" i
tag(i) = @sprintf("X%02d", i)
function parse_cf(fn)
dat = readdlm(fn)
cf = Dict{NTuple{2,Int},Array{<:Real,1}}()
Expand All @@ -14,7 +17,7 @@ function parse_cf(fn)
end

function run(args)
t0 = now()
t0 = time()
cfgf = args[1]
@info("Loading parameters from $(cfgf)")
cfg = open(YAML.load, cfgf)
Expand All @@ -37,7 +40,7 @@ cfs = parse_cf(cf_fn)

# build system
@info("Building system...")
t0_sys = now()
t0_sys = time()
s = System("G")
#energy!(s, "G", 0)
#push!(s.grounds, "G")
Expand All @@ -57,13 +60,13 @@ for (i, j) in keys(cfs)
lut = LineshapeLUT(t->(GriddedCF(cfs[i,j], dt)(t)+g_inhomo(t, ev2angphz(σ))), lut_grid)
lineshape!(s, ti, tj, lut)
end
@info(" Took $(now()-t0_sys)")
@info(" Took $(time()-t0_sys)")
@info("Number of order 1 Hilbert Paths: $(length(collect(hilbert_paths(s, 1))))")
@info("Number of order 3 Hilbert Paths: $(length(collect(hilbert_paths(s, 3))))")

grd_lin = TimeGrid(t1)

t0_calc = now()
t0_calc = time()
out_root = cfg["rootname"]

# compute them separately
Expand All @@ -82,8 +85,8 @@ f_lin = fftshift(fftfreq(size(grd_lin)[1], 1/(grd_lin.times[1][2]-grd_lin.times[
@info("Saving linear spectrum to $(out_root)_slin.txt")
writedlm("$(out_root)_slin.txt", [f_lin real(s_lin) imag(s_lin)])

@info(" Took $(now()-t0_calc)")
@info("Total runtime: $(now()-t0)")
@info(" Took $(time()-t0_calc)")
@info("Total runtime: $(time()-t0)")
end # run

run(ARGS)
Loading

0 comments on commit 9861ace

Please sign in to comment.