Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
47 commits
Select commit Hold shift + click to select a range
d1c20a4
Add basic sample_model and tests
henrikjacobsenfys Oct 14, 2025
a782693
Clean up, fix tests
henrikjacobsenfys Oct 15, 2025
2fb844b
Improve tests
henrikjacobsenfys Oct 17, 2025
d4309fc
Update example and tests
henrikjacobsenfys Oct 17, 2025
cde9b4b
Add one more test
henrikjacobsenfys Oct 17, 2025
6f797f8
Added a few tests
henrikjacobsenfys Oct 17, 2025
3435da5
a few more tests
henrikjacobsenfys Oct 17, 2025
c0a4f2c
fix a test
henrikjacobsenfys Oct 17, 2025
a4ba794
respond to PR comments
henrikjacobsenfys Oct 17, 2025
d1d28d2
Use CollectionBase
henrikjacobsenfys Oct 20, 2025
ce49f05
Update example
henrikjacobsenfys Oct 20, 2025
0eb1bba
Merge branch 'develop' into SampleModel2
henrikjacobsenfys Oct 28, 2025
07c070a
Update to new ModelComponent
henrikjacobsenfys Oct 28, 2025
3a7187c
Cleanup and a few tests
henrikjacobsenfys Oct 28, 2025
8aa43c0
Respond to reviewer comments
henrikjacobsenfys Nov 1, 2025
28d0b0e
Tests :)
henrikjacobsenfys Nov 1, 2025
a41277b
Get rid of CollectionBase
henrikjacobsenfys Nov 13, 2025
e39a18e
add test of containts
henrikjacobsenfys Nov 13, 2025
8d3ad4d
Remove outcommented code
henrikjacobsenfys Nov 13, 2025
0d3e3eb
update docstring
henrikjacobsenfys Nov 13, 2025
d341fc4
Brownian diffusion
henrikjacobsenfys Nov 17, 2025
87c597b
update notebook
henrikjacobsenfys Nov 17, 2025
f20663c
Tests
henrikjacobsenfys Nov 18, 2025
8907f65
Tiny change to trigger actions
henrikjacobsenfys Nov 18, 2025
fb45ae5
Minor change to trigger codecov
henrikjacobsenfys Nov 19, 2025
4543ef7
Update model_component to NewBase
henrikjacobsenfys Dec 10, 2025
844d414
Update model_component and tests
henrikjacobsenfys Dec 10, 2025
c155a7d
update model_component
henrikjacobsenfys Dec 11, 2025
bde91b5
Update gaussian
henrikjacobsenfys Dec 11, 2025
fa50c93
update Lorentzian
henrikjacobsenfys Dec 11, 2025
ce8df0e
update DHO
henrikjacobsenfys Dec 11, 2025
6ade763
update delta function
henrikjacobsenfys Dec 11, 2025
da2462c
Update voigt
henrikjacobsenfys Dec 11, 2025
6d5a6af
Update Polynomial
henrikjacobsenfys Dec 11, 2025
6ccd646
Small updates to component docstrings
henrikjacobsenfys Dec 11, 2025
cdd208b
Update sample_model
henrikjacobsenfys Dec 11, 2025
7a5dd45
rename to ComponentCollection
henrikjacobsenfys Dec 12, 2025
4f7608e
Add a few tests, simplify polynomial
henrikjacobsenfys Dec 12, 2025
2d9c134
Update examples
henrikjacobsenfys Dec 12, 2025
a39e061
Merge branch 'SampleModel2' into diffusion-model
henrikjacobsenfys Dec 12, 2025
2ce2960
Update diffusion
henrikjacobsenfys Dec 12, 2025
61f79a1
Update diffusion base class to use the new base
henrikjacobsenfys Dec 12, 2025
26ebcec
Update to use the new base
henrikjacobsenfys Dec 12, 2025
ed8e5bf
Update example
henrikjacobsenfys Dec 12, 2025
bbd705f
Update tests
henrikjacobsenfys Dec 12, 2025
5fd80b4
Another test
henrikjacobsenfys Dec 12, 2025
d251f22
100% coverage
henrikjacobsenfys Dec 12, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
83 changes: 83 additions & 0 deletions examples/component_collection.ipynb
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
{
"cells": [
{
"cell_type": "code",
"execution_count": null,
"id": "64deaa41",
"metadata": {},
"outputs": [],
"source": [
"import numpy as np\n",
"\n",
"from easydynamics.sample_model import Gaussian\n",
"from easydynamics.sample_model import Lorentzian\n",
"from easydynamics.sample_model import DampedHarmonicOscillator\n",
"from easydynamics.sample_model import Polynomial\n",
"\n",
"from easydynamics.sample_model import ComponentCollection\n",
"\n",
"\n",
"import matplotlib.pyplot as plt\n",
"\n",
"\n",
"%matplotlib widget"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "784d9e82",
"metadata": {},
"outputs": [],
"source": [
"component_collection=ComponentCollection()\n",
"\n",
"# Creating components\n",
"gaussian=Gaussian(display_name='Gaussian',width=0.5,area=1)\n",
"dho = DampedHarmonicOscillator(display_name='DHO',center=1.0,width=0.3,area=2.0)\n",
"lorentzian = Lorentzian(display_name='Lorentzian',center=-1.0,width=0.2,area=1.0)\n",
"polynomial = Polynomial(display_name='Polynomial',coefficients=[0.1, 0, 0.5]) # y=0.1+0.5*x^2\n",
"\n",
"# Adding components to the component collection\n",
"component_collection.add_component(gaussian)\n",
"component_collection.add_component(dho)\n",
"component_collection.add_component(lorentzian)\n",
"component_collection.add_component(polynomial)\n",
"\n",
"x=np.linspace(-2, 2, 100)\n",
"\n",
"plt.figure()\n",
"y=component_collection.evaluate(x)\n",
"plt.plot(x, y, label='Component collection')\n",
"\n",
"for component in component_collection.components:\n",
" y = component.evaluate(x)\n",
" plt.plot(x, y, label=component.display_name)\n",
"\n",
"plt.legend()\n",
"plt.show()"
]
}
],
"metadata": {
"kernelspec": {
"display_name": "easydynamics_newbase",
"language": "python",
"name": "python3"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.12.12"
}
},
"nbformat": 4,
"nbformat_minor": 5
}
18 changes: 9 additions & 9 deletions examples/component_example.ipynb → examples/components.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
"import matplotlib.pyplot as plt\n",
"\n",
"\n",
"%matplotlib widget"
"%matplotlib widget\n"
]
},
{
Expand All @@ -30,10 +30,10 @@
"outputs": [],
"source": [
"# Creating a component\n",
"gaussian=Gaussian(name='Gaussian',width=0.5,area=1)\n",
"dho = DampedHarmonicOscillator(name='DHO',center=1.0,width=0.3,area=2.0)\n",
"lorentzian = Lorentzian(name='Lorentzian',center=-1.0,width=0.2,area=1.0)\n",
"polynomial = Polynomial(name='Polynomial',coefficients=[0.1, 0, 0.5]) # y=0.1+0.5*x^2\n",
"gaussian=Gaussian(display_name='Gaussian',width=0.5,area=1)\n",
"dho = DampedHarmonicOscillator(display_name='DHO',center=1.0,width=0.3,area=2.0)\n",
"lorentzian = Lorentzian(display_name='Lorentzian',center=-1.0,width=0.2,area=1.0)\n",
"polynomial = Polynomial(display_name='Polynomial',coefficients=[0.1, 0, 0.5]) # y=0.1+0.5*x^2\n",
"\n",
"x=np.linspace(-2, 2, 100)\n",
"\n",
Expand Down Expand Up @@ -72,7 +72,7 @@
"metadata": {},
"outputs": [],
"source": [
"delta = DeltaFunction(name='Delta', center=0.0, area=1.0)\n",
"delta = DeltaFunction(display_name='Delta', center=0.0, area=1.0)\n",
"x1=np.linspace(-2, 2, 100)\n",
"y=delta.evaluate(x1)\n",
"x2=np.linspace(-2,2,51)\n",
Expand Down Expand Up @@ -100,7 +100,7 @@
"x1=sc.linspace(dim='x', start=-2.0, stop=2.0, num=100, unit='meV')\n",
"x2=sc.linspace(dim='x', start=-2.0*1e3, stop=2.0*1e3, num=101, unit='microeV')\n",
"\n",
"polynomial = Polynomial(name='Polynomial',coefficients=[0.1, 0, 0.5]) # y=0.1+0.5*x^2\n",
"polynomial = Polynomial(display_name='Polynomial',coefficients=[0.1, 0, 0.5]) # y=0.1+0.5*x^2\n",
"y1=polynomial.evaluate(x1)\n",
"y2=polynomial.evaluate(x2)\n",
"\n",
Expand All @@ -114,7 +114,7 @@
],
"metadata": {
"kernelspec": {
"display_name": "newdynamics",
"display_name": "easydynamics_newbase",
"language": "python",
"name": "python3"
},
Expand All @@ -128,7 +128,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.11.13"
"version": "3.12.12"
}
},
"nbformat": 4,
Expand Down
92 changes: 7 additions & 85 deletions examples/detailed_balance.ipynb

Large diffs are not rendered by default.

77 changes: 77 additions & 0 deletions examples/diffusion_model.ipynb
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
{
"cells": [
{
"cell_type": "code",
"execution_count": null,
"id": "64deaa41",
"metadata": {},
"outputs": [],
"source": [
"import numpy as np\n",
"\n",
"from easydynamics.sample_model import BrownianTranslationalDiffusion\n",
"\n",
"import matplotlib.pyplot as plt\n",
"\n",
"%matplotlib widget"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "784d9e82",
"metadata": {},
"outputs": [],
"source": [
"# Create Brownian Translational Diffusion model and plot the model for different Q values.\n",
"# Q is in Angstrom^-1 and energy in meV.\n",
"\n",
"Q=np.linspace(0.5,2,7)\n",
"energy=np.linspace(-2, 2, 501)\n",
"scale=1.0\n",
"diffusion_coefficient = 2.4e-9 # m^2/s\n",
"diffusion_unit= \"m**2/s\"\n",
"\n",
"diffusion_model=BrownianTranslationalDiffusion(display_name=\"DiffusionModel\", scale=scale, diffusion_coefficient= diffusion_coefficient, diffusion_unit=diffusion_unit)\n",
"\n",
"component_collections=diffusion_model.create_component_collections(Q)\n",
"\n",
"\n",
"cmap = plt.cm.jet\n",
"nQ = len(component_collections)\n",
"plt.figure()\n",
"for Q_index in range(len(component_collections)):\n",
" color = cmap(Q_index / (nQ - 1))\n",
" y=component_collections[Q_index].evaluate(energy)\n",
" plt.plot(energy, y, label=f'Q={Q[Q_index]} Å^-1',color=color)\n",
" \n",
"plt.legend()\n",
"plt.show()\n",
"plt.xlabel('Energy (meV)')\n",
"plt.ylabel('Intensity (arb. units)')\n",
"plt.title('Brownian Translational Diffusion Model') "
]
}
],
"metadata": {
"kernelspec": {
"display_name": "easydynamics_newbase",
"language": "python",
"name": "python3"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.12.12"
}
},
"nbformat": 4,
"nbformat_minor": 5
}
6 changes: 5 additions & 1 deletion src/easydynamics/sample_model/__init__.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
from .component_collection import ComponentCollection
from .components import (
DampedHarmonicOscillator,
DeltaFunction,
Expand All @@ -6,13 +7,16 @@
Polynomial,
Voigt,
)
from .diffusion_model import BrownianTranslationalDiffusion, DiffusionModel

__all__ = [
"SampleModel",
"ComponentCollection",
"Gaussian",
"Lorentzian",
"Voigt",
"DeltaFunction",
"DampedHarmonicOscillator",
"Polynomial",
"DiffusionModel",
"BrownianTranslationalDiffusion",
]
Loading