Code Monkey home page Code Monkey logo

spidy.jl's Introduction

spidy_banner

SpiDy.jl

Stable Dev Build Status DOI DOI

(It is pronounced "spee-dee" ๐Ÿ˜Š)

SpiDy.jl is a Julia package that solves the non-Markovian stochastic dynamics of interacting classical spin vectors and harmonic oscillator networks in contact with a dissipative environment. The methods implemented allow the user to include arbitrary memory effects and colored quantum noise spectra. In this way, SpiDy.jl provides key tools for the simulation of classical and quantum open systems including non-Markovian effects and arbitrarily strong coupling to the environment. Among the wide range of applications, some examples range from atomistic spin dynamics to ultrafast magnetism and the study of anisotropic materials. We provide the user with Julia notebooks to guide them through the various mathematical methods and help them quickly set up complex simulations.

Reference paper

This is the reference paper for a quick overview. You might also want to cite it in case it is useful!

JOSS publication -> https://joss.theoj.org/papers/10.21105/joss.06263

arXiv preprint -> https://arxiv.org/abs/2310.03008

Bibtex citation
@article{Scali2024,
  doi = {10.21105/joss.06263},
  url = {https://doi.org/10.21105/joss.06263},
  year = {2024},
  publisher = {The Open Journal},
  volume = {9},
  number = {97},
  pages = {6263},
  author = {Stefano Scali and Simon Horsley and Janet Anders and Federico Cerisola},
  title = {SpiDy.jl: open-source Julia package for the study of non-Markovian stochastic dynamics},
  journal = {Journal of Open Source Software}
}

Online documentation

Check the online documentation at this link.

Install Julia

If you are new to Julia, here is how to install it.

If you are a Windows/Mac user, download Julia here and run the installer. On Mac, drag-and-drop the app to the Applications.

If you are a Linux user, just open a terminal and use your package manager, e.g. on Debian-based distros run "sudo apt-get install julia", on RedHat-based distros run "sudo dnf install julia".

Install SpiDy

Start Julia and enter in Pkg REPL mode by pressing ] then run the following,

add SpiDy

NB: the entire installation of SpiDy and its dependencies takes about 5 minutes on a bare-bones Julia environment.

Run SpiDy

To run the code,

  • save run_dynamics.jl and run_steadystate.jl in your preferred location (open the link -> right click on the page -> save as... should work to save the file)
  • open the terminal or command line
  • run the following command,
julia "path-to-your-file"/run_dynamics.jl

where "path-to-your-file" is the one where you saved your file. Replace run_dynamics.jl with run_steadystate.jl to run the one of your choice.

This last command will run the code and save plots/datafile of the chosen run. CONGRATS, you have just run SpiDy for the first time!

NB: the code can exploit parallel computation. To do this, run your files as

julia -t 6 "path-to-your-file"/run_dynamics.jl

where you want to replace "6" with the number of threads that you wish to use. As a general idea, you do not want to use more than 80% of the number of threads you have available in your machine, e.g. if you have a 4-core CPU, you are likely to have 8 threads and you may want to run the parallelization as indicated above.

Repo structure

  • .github/workflows: contains the yml file to build the documentation and commit on the gh-pages branch
  • docs: contains the logos, make.jl and index.md for the generation of documentation
  • runs: contains run_*.jl files which can be used as a template to run the code
  • src: contains the source code
  • starthere: contains an ipynb notebook written in Julia which walks you through bits and pieces of the code with explanatory plots (the notebook is evolving over time but always ready to use)

spidy.jl's People

Contributors

cerisola avatar mekise avatar quantum-charlie avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

spidy.jl's Issues

Testing

JOSS requires sufficient testing for correctness.
It looks like SpectralDensities.jl tests for quite a few things, but SpiDy.jl only checks the code runs, not that the output is sensible.

It would be good to add a few tests that check output values, preferably some physically significant result, but reproducibility against a specific random seed is also okay.

Rename dynamics solver functions

Currently, all dynamics functions are called diffeqsolver, which, while to the point of what it does, might not be the clearest name for a new user. Furthermore, it makes the spin vs harmonic-oscillator difference very subtle (maybe this is good?).

We could rename these functions, so that they are more explicit, e.g. spin_dynamics(...) and harmonic_osc_dynamics(...) (or something like stochastic_dynamics(...) if we want to keep the same name for both).

To keep backwards compatibility, we could still define the diffeqsolver function names, so if current users update the library, their code keeps running (once we have proper releases and versioning, we can then drop the backwards compatibility at an appropriate major release).

TagBot trigger issue

This issue is used to trigger TagBot; feel free to unsubscribe.

If you haven't already, you should update your TagBot.yml to include issue comment triggers.
Please see this post on Discourse for instructions and more details.

If you'd like for me to do this for you, comment TagBot fix on this issue.
I'll open a PR within a few hours, please be patient!

Geweke-like diagnostic to verify steady state convergence

Is your feature request related to a problem? Please describe.
There is no test in place to verify convergence. While this is not always needed, we should consider adding an optional parameter to turn it on.

Describe the solution you'd like
Add a parameter to diffeqsolver to turn on the convergence check. Use https://turinglang.org/MCMCDiagnosticTools.jl/stable/#MCMCDiagnosticTools.gewekediag maybe?

Describe alternatives you've considered
Make our own test, nothing fancy, something checking the first couple of moments?

Errors using example run files with latest version of DifferentialEquations.jl

Newer versions of DifferentialEquations.jl (and its dependency RecursiveArrayTools.jl) changed the way the solution can be accessed as an array, causing the example run files to error out. Indeed, when running the dynamic files, result in the following error:

% julia run/run_dynamics.jl
Starting...
ERROR: LoadError: TaskFailedException

    nested task error: AssertionError: length(I) == ndims(A.u)
    Stacktrace:
   ....

Apparently, the way the solution was used as an array, although it worked fine before, it was never officially supported (see: SciML/DifferentialEquations.jl#1021). The official way to access the solution from DifferentialEquations.jl is to do `Array(sol)'.

[JOSS Review]: Suggested paper revisions

These are some comments to help the paper component of openjournals/joss-reviews#6263 be more compliant with a JOSS paper.

SpiDy.jl/paper/paper.md

Lines 17 to 21 in 8e7e98c

- name: Simon Horsley
orcid: 0000-0001-7242-7941
affiliation: 1
- name: Janet Anders
orcid: 0000-0002-9791-0363

  • In

A further set of applications stems from the extension of SpiDy.jl to handle the non-Markovian stochastic dynamics of harmonic oscillators. This model will be of interest in the field of quantum thermodynamics where harmonic oscillators play a key role in modeling open quantum systems. The package is written in pure Julia and we take advantage of the efficient DifferentialEquations.jl package by reducing evaluation redundancy, using callbacks, and pre-allocations.

specifically

The package is written in pure Julia and we take advantage of the efficient DifferentialEquations.jl package...

please cite DifferentialEquations.jl. They provide a CITATION.bib:

@article{DifferentialEquations.jl-2017,
 author = {Rackauckas, Christopher and Nie, Qing},
 doi = {10.5334/jors.151},
 journal = {The Journal of Open Research Software},
 keywords = {Applied Mathematics},
 note = {Exported from https://app.dimensions.ai on 2019/05/05},
 number = {1},
 pages = {},
 title = {DifferentialEquations.jl โ€“ A Performant and Feature-Rich Ecosystem for Solving Differential Equations in Julia},
 url = {https://app.dimensions.ai/details/publication/pub.1085583166 and http://openresearchsoftware.metajnl.com/articles/10.5334/jors.151/galley/245/download/},
 volume = {5},
 year = {2017}
}
  • All of the "Example" section should be removed. While I understand the motivation to include it, in the What should my paper contain? JOSS docs examples are not a requested paper section and we recommend adding all such useful examples to the documentation, if they are not already there.

  • While the "Overview" section is not requested, if it is important to you to keep it you may, but it will need to be reduced in scope. As noted in the docs, the paper should include

A summary describing the high-level functionality and purpose of the software for a diverse, non-specialist audience.

where "non-specialist" means someone outside of your field. You could probably reduce this entire section down to a modified version of

SpiDy.jl/paper/paper.md

Lines 78 to 84 in 8e7e98c

In conclusion, SpiDy.jl implements the stochastic dynamics of coupled integro-differential equations to model systems of interacting spins or harmonic oscillator networks subject to environment noise.
Among others, some of the key features of the package include:
- Coloured stochastic noise that satisfies the FDR and accounts for both classical and quantum bath statistics.
- Simulation of non-Markovian system dynamics due to the memory kernel $K_n(t)$.
- Custom system-environment coupling tensors, allowing for isotropic or anisotropic couplings. Both amplitudes and geometry of the coupling can be specified.
- Choice between local environments, i.e. distinct baths acting on the single sub-system, or a single common environment.

though I appreciate that you might feel the need to give a bit more supporting detail, which is fine.

Beyond that I think the paper is great and once this is done we can move forward with the versioning and archiving steps of publishing. ๐Ÿ‘

Please let me know of any questions or concerns that you might have, and I'll be happy to try to help address them.

Make default distribution argument of bfield more explicit

Currently, the bfield distribution argument takes a default value of nothing, i.e.

function bfield(N, ฮ”t, J::GenericSD, noise::Noise, distro=nothing)
    if isnothing(distro)
        distro = Normal(0., 1/sqrt(ฮ”t))
    end
   ...
end

which is then initialised to a Normal distribution as shown.

Apparently, Julia allows for default arguments to depend on the mandatory values. That is, something like this should work:

function bfield(N, ฮ”t, J::GenericSD, noise::Noise, distro=Normal(0., 1/sqrt(ฮ”t)))
   ...
end

If possible to do it this way, I think it would be an improvement as it would be clearer to the user what the default of nothing is actually doing.

Superflous constructor in IsoCoupling

From what I remember of the code you showed me on Friday, the constructor IsoCoupling(C) = C*I in the current version of the IsoCoupling type:

struct IsoCoupling{TT<:Real} <: Coupling
    C::TT
    IsoCoupling(C) = C*I
end

should not be there since it is not used for anything in the latest version. Indeed in the notebook where you were trying stuff in the office it shouldn't be there if I recall right.

Community guidelines

Submissions to JOSS require some form of community guidelines for contributing to the code.
In general, this takes the form of a contributing file as explained here, and here is an example of the content of the file.

SpectralDensities.jl will also need one since it is covered in the JOSS publication.

If you want to go further (not required for JOSS) and add a code of conduct, PR and issue templates, github's community profile page is not bad place to start

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.