Skip to content

Commit

Permalink
Add example to docs
Browse files Browse the repository at this point in the history
  • Loading branch information
oashour committed May 2, 2024
1 parent 6d94b7d commit 02d6ebc
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 34 deletions.
36 changes: 36 additions & 0 deletions docs/examples.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
# Examples

More examples coming soon

## Light Scalar Mediator, Single Phonons, Solid He


This will be run from a Jupyter notebook or as a python script
```python
import numpy as np

from darkmagic import Calculator, MaterialParameters, PhononMaterial, Numerics
from darkmagic.benchmark_models import light_scalar_mediator

# Masses in eV and times of day in hours (to calculate the earth's velocity)
masses = np.logspace(4, 10, 96)
times = [0]

# Phonons in Helium
params = MaterialParameters(N={"e": [2, 2], "n": [2, 2], "p": [2, 2]})
material = PhononMaterial("hcp_He", params, "tests/data/hcp_He_1GPa.phonopy.yaml")
model = light_scalar_mediator

# Numerics
numerics = Numerics(
N_grid=[80, 40, 40], # Spherical grid for momentum transfer
N_DWF_grid=[30, 30, 30], # Monkhorst-Pack grid for Debye-Waller factor
)

# Create calculator object
full_calc = Calculator("scattering", masses, material, model, numerics, times)
full_calc.evaluate() # Run calculation
full_calc.to_file() # Write HDF5 file (default name is "material.name_model.name.h5")
```

To run in parallel, simply run with `srun -n <nprocs> python script.py` or whatever alternative your system uses.
34 changes: 0 additions & 34 deletions docs/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,37 +23,3 @@ DarkMAGIC is currently in pre-alpha testing, so not all features are implemented
* Multi-phonon processes
* Absorption
* Support for fully first-principles time-dependent DFT magnon calculations instead of just spin Hamiltonians.

# Example

More examples coming soon

This will be run from a Jupyter notebook or as a python script
```python
import numpy as np

from darkmagic import Calculator, MaterialParameters, PhononMaterial, Numerics
from darkmagic.benchmark_models import light_scalar_mediator

# Masses in eV and times of day in hours (to calculate the earth's velocity)
masses = np.logspace(4, 10, 96)
times = [0]

# Phonons in Helium
params = MaterialParameters(N={"e": [2, 2], "n": [2, 2], "p": [2, 2]})
material = PhononMaterial("hcp_He", params, "tests/data/hcp_He_1GPa.phonopy.yaml")
model = light_scalar_mediator

# Numerics
numerics = Numerics(
N_grid=[80, 40, 40], # Spherical grid for momentum transfer
N_DWF_grid=[30, 30, 30], # Monkhorst-Pack grid for Debye-Waller factor
)

# Create calculator object
full_calc = Calculator("scattering", masses, material, model, numerics, times)
full_calc.evaluate() # Run calculation
full_calc.to_file() # Write HDF5 file (default name is "material.name_model.name.h5")
```

To run in parallel, simply run with `srun -n <nprocs> python script.py` or whatever your system uses.

0 comments on commit 02d6ebc

Please sign in to comment.