This hopefully will become a Julia wrapper of the MULTEM simulation package for electron microsscopy. At the moment, this is used to test using TOML as an input file format.
Juila: Downloads and Documentation
Open a Julia REPL, then press ]
to use the package mode.
pkg> dev https://github.com/chenspc/MULTEM.jl
Go back to the normal mode by pressing backspace
, then
julia> using MULTEM
There is a default.toml
in the test
folder, which can be imported as a dictionary simply with the TOML.jl package.
julia> using TOML
julia> default_toml = TOML.parsefile("default.toml")
Dict{String,Any} with 5 entries:
"theory" => Dict{String,Any}("electron_phonon_interaction"=>Dict{String,Any}("mode…
"instrument" => Dict{String,Any}("incident_wave"=>Dict{String,Any}("psi"=>0.0,"theta"=…
"specimen" => Dict{String,Any}("rotation"=>Dict{String,Any}("theta"=>0.0,"center_typ…
"simulation" => Dict{String,Any}("output_region"=>Dict{String,Any}("ix_0"=>0.0,"iy_e"=…
"system" => Dict{String,Any}("cpu_nthreads"=>1,"cpu_ncores"=>1,"device"=>2,"gpu_de…
This can then be converted to a more organised struct MULTEMInput
for ease of use.
julia> m = from_dict(MULTEMInput, default_toml)
MULTEMInput()
Default values are by default not printed here, but those fields and values do exist. m
can be converted back to a dictionary with to_dict
. Use the include_defaults=true
keyword if needed.
julia> m_dict = to_dict(m; include_defaults=true)
OrderedCollections.OrderedDict{String,Any} with 5 entries:
"system" => OrderedCollections.OrderedDict{String,Any}("cpu_nthreads"=>1,"cpu_ncor…
"theory" => OrderedCollections.OrderedDict{String,Any}("electron_phonon_interactio…
"simulation" => OrderedCollections.OrderedDict{String,Any}("output_region"=>OrderedCol…
"specimen" => OrderedCollections.OrderedDict{String,Any}("rotation"=>OrderedCollecti…
"instrument" => OrderedCollections.OrderedDict{String,Any}("incident_wave"=>OrderedCol…
Or use to_toml
to generate a TOML string.
julia> m_toml = to_toml(m; include_defaults=true)
...
...
to_toml
can also be used to directly save the TOML string to file.
julia> to_toml("/<some_path>/default_out.toml", m; include_defaults=true)