Skip to content

Commit

Permalink
Update documents
Browse files Browse the repository at this point in the history
  • Loading branch information
ohno committed Feb 8, 2024
1 parent 7f62365 commit d229b00
Show file tree
Hide file tree
Showing 9 changed files with 317 additions and 117 deletions.
7 changes: 4 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -65,9 +65,10 @@ This is the guideline for adding new models.
6. Write the code in that file. First we need to create a structure `struct ModelName` with the same name as the model name (The best way is Find & Replace). Create V, E, ψ and other functions. Because the function names conflict, you must always give the structure as an argument. Multi-dispatch avoids conflict. We recommend using Revice.jl while coding. Run `include("./developer/revice.jl")` on the REPL or use dev.ipynb.
7. Add test code test/ModelName.jl. At a minimum, it is recommended to check the normalization and the orthogonality of wavefunction using QuadGK.jl. All tests will be executed by executing `include("./developer/test.jl")`. It will take about 2 minutes to complete.
8. Add documentation. Add either docs/ModelName.md or docs/jmd/ModelName.jmd (if you have a jmd file, the md file will be automatically generated). Include at least the definition of the Hamiltonian and the analytical solutions (eigenvalues and eigenfunctions).
9. Execute `include("./developer/docs.jl")` to compile. Please check docs/build/*.html in your browser.
10. Push the code.
11. Submit a pull request on GitHub.
9. Add the new model into `pages=[...]` in docs/make.jl.
10. Execute `include("./developer/docs.jl")` to compile. Please check docs/build/*.html in your browser.
11. Push the code.
12. Submit a pull request on GitHub.

## Acknowledgment

Expand Down
307 changes: 229 additions & 78 deletions developer/dev.ipynb

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion docs/jmd2md.jl
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
using Antique
using Weave

for file in Antique.models # [:InfinitePotentialWell :HarmonicOscillator :MorsePotential :HydrogenAtom]
for file in Antique.models # [:DeltaPotential]
weave("./src/jmd/$file.jmd", doctype="github", out_path="./src/", fig_path="./assets/fig/")
text = Antique.load("./src/$file.md")
# remove ``` after include(...s)
Expand Down
34 changes: 19 additions & 15 deletions docs/src/DeltaPotential.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,39 +4,43 @@ CurrentModule = Antique

# Delta Potential

The Delta potential is one the simplest models for quantum mechanical system in 1D.
The Delta potential is one of the simplest models for quantum mechanical system in 1D.
It always has one bound state and its wave function has a cusp at the origin.

## Defitions

``\alpha`` is the potential strength, ``m`` is the mass of particle.
This model is described with the time-independent Schrödinger equation

#### Schrödinger Equation
```math
\hat{H} \psi(x) = E \psi(x)
\hat{H} \psi(x) = E \psi(x),
```

#### Hamiltonian
and the Hamiltonian
```math
\hat{H} = - \frac{\hbar^2}{2m} \frac{\mathrm{d}^2}{\mathrm{d}x ^2} + V(x)
\hat{H} = - \frac{\hbar^2}{2m} \frac{\mathrm{d}^2}{\mathrm{d}x ^2} + V(x).
```

Parameters are specified with the following struct.

#### Parameters

```@docs
DeltaPotential
```

#### Potential
`V(model::DeltaPotential; x)`
```math
V(x) = -\alpha \delta(x).
```@docs
V(::DeltaPotential)
```

#### Eigen Values
`E(model::DeltaPotential)`
```math
E = - \frac{m\alpha^2}{2\hbar^2}
```@docs
E(::DeltaPotential)
```

#### Eigen Functions
`ψ(model::DeltaPotential, x)`
```math
\psi(x) = \frac{\sqrt{m\alpha}}{\hbar} \mathrm{e}^{-m\alpha |x|/\hbar^2}
```@docs
ψ(::DeltaPotential)
```

## Usage & Examples
Expand Down
Binary file modified docs/src/assets/fig/DeltaPotential_4_1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
13 changes: 10 additions & 3 deletions docs/src/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,12 @@ There are more examples on each model page.
</a>
<code>HydrogenAtom</code>
</div>
<div class="item">
<a target="_blank" href="./DeltaPotential">
<img src="assets/fig/DeltaPotential_4_1.png" alt="DeltaPotential"/>
</a>
<code>DeltaPotential</code>
</div>
</div>
```

Expand All @@ -89,9 +95,10 @@ This is the guideline for adding new models.
6. Write the code in that file. First we need to create a structure `struct ModelName` with the same name as the model name (The best way is Find & Replace). Create V, E, ψ and other functions. Because the function names conflict, you must always give the structure as an argument. Multi-dispatch avoids conflict. We recommend using Revice.jl while coding. Run `include("./developer/revice.jl")` on the REPL or use dev.ipynb.
7. Add test code test/ModelName.jl. At a minimum, it is recommended to check the normalization and the orthogonality of wavefunction using QuadGK.jl. All tests will be executed by executing `include("./developer/test.jl")`. It will take about 2 minutes to complete.
8. Add documentation. Add either docs/ModelName.md or docs/jmd/ModelName.jmd (if you have a jmd file, the md file will be automatically generated). Include at least the definition of the Hamiltonian and the analytical solutions (eigenvalues and eigenfunctions).
9. Execute `include("./developer/docs.jl")` to compile. Please check docs/build/*.html in your browser.
10. Push the code.
11. Submit a pull request on GitHub.
9. Add the new model into `pages=[...]` in docs/make.jl.
10. Execute `include("./developer/docs.jl")` to compile. Please check docs/build/*.html in your browser.
11. Push the code.
12. Submit a pull request on GitHub.

## Acknowledgment

Expand Down
34 changes: 19 additions & 15 deletions docs/src/jmd/DeltaPotential.jmd
Original file line number Diff line number Diff line change
Expand Up @@ -4,39 +4,43 @@ CurrentModule = Antique

# Delta Potential

The Delta potential is one the simplest models for quantum mechanical system in 1D.
The Delta potential is one of the simplest models for quantum mechanical system in 1D.
It always has one bound state and its wave function has a cusp at the origin.

## Defitions

``\alpha`` is the potential strength, ``m`` is the mass of particle.
This model is described with the time-independent Schrödinger equation

#### Schrödinger Equation
```math
\hat{H} \psi(x) = E \psi(x)
\hat{H} \psi(x) = E \psi(x),
```

#### Hamiltonian
and the Hamiltonian
```math
\hat{H} = - \frac{\hbar^2}{2m} \frac{\mathrm{d}^2}{\mathrm{d}x ^2} + V(x)
\hat{H} = - \frac{\hbar^2}{2m} \frac{\mathrm{d}^2}{\mathrm{d}x ^2} + V(x).
```

Parameters are specified with the following struct.

#### Parameters

```@docs
DeltaPotential
```

#### Potential
`V(model::DeltaPotential; x)`
```math
V(x) = -\alpha \delta(x).
```@docs
V(::DeltaPotential)
```

#### Eigen Values
`E(model::DeltaPotential)`
```math
E = - \frac{m\alpha^2}{2\hbar^2}
```@docs
E(::DeltaPotential)
```

#### Eigen Functions
`ψ(model::DeltaPotential, x)`
```math
\psi(x) = \frac{\sqrt{m\alpha}}{\hbar} \mathrm{e}^{-m\alpha |x|/\hbar^2}
```@docs
ψ(::DeltaPotential)
```

## Usage & Examples
Expand Down
35 changes: 34 additions & 1 deletion src/DeltaPotential.jl
Original file line number Diff line number Diff line change
Expand Up @@ -26,4 +26,37 @@ function ψ(model::DeltaPotential, x)
m = model.m
= model.
return sqrt(m*α)/* exp.(-m*α*abs.(x)/^2)
end
end

# Documents

@doc raw"""
`DeltaPotential(α=1.0, m=1.0, ℏ=1.0)`
``\alpha`` is the potential strength, ``m`` is the mass of particle and ``\hbar`` is the reduced Planck constant (Dirac's constant).
""" DeltaPotential

@doc raw"""
`V(model::DeltaPotential; x)`
```math
V(x) = -\alpha \delta(x).
```
""" V(model::DeltaPotential)

@doc raw"""
`E(model::DeltaPotential)`
```math
E = - \frac{m\alpha^2}{2\hbar^2}
```
""" E(model::DeltaPotential)

@doc raw"""
`ψ(model::DeltaPotential, x)`
```math
\psi(x) = \frac{\sqrt{m\alpha}}{\hbar} \mathrm{e}^{-m\alpha |x|/\hbar^2}
```
""" ψ(model::DeltaPotential)
2 changes: 1 addition & 1 deletion test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ using LaTeXStrings
using SpecialFunctions

@testset "Antique.jl" begin
for model in [:DeltaPotential] # Antique.models
for model in Antique.models # [:DeltaPotential]
result = @capture_out begin
include("./$(model).jl")
end
Expand Down

0 comments on commit d229b00

Please sign in to comment.