Skip to content

Commit

Permalink
Initial release
Browse files Browse the repository at this point in the history
This is the version corresponding to the original submission of the first
theory/proposal publication.
  • Loading branch information
jokuha committed Sep 28, 2023
1 parent 55b367a commit 847d919
Show file tree
Hide file tree
Showing 22 changed files with 1,734 additions and 2 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
__pycache__
*.egg-info
*.h5
12 changes: 12 additions & 0 deletions Contributors.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
This project was started by Muhamed Amin based on ideas and suggestions from
Jochen Küpper. Jean-Michel Hartmann provided Fortran code, based on the book
<add>.



<!-- Put Emacs local variables into HTML comment
Local Variables:
coding: utf-8
fill-column: 80
End:
-->
618 changes: 618 additions & 0 deletions LICENSE-GPLv3.md

Large diffs are not rendered by default.

22 changes: 22 additions & 0 deletions LICENSE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# CMIclassirot licensing conditions

CMIclassirot is provided by the CFEL Controlled Molecule Imaging group as is. It is licensed under
the [GPL v3](./LICENSE-GPLv3.md) with the following additional requirements:

* Its use for scientific work is acknowledged by the appropriate reference in any resulting work,
e.g., scientific publication.

* All corrections and enhancements must be contributed back to the development of the package within
an appropriate time, i.e., no later than the publication of its first use.
Please create a pull request on GitHub (preferred) or send an appropriate patch against the latest
program version on the `develop` branch.

See the documentation for a full list of contributors.


<!-- Put Emacs local variables into HTML comment
Local Variables:
coding: utf-8
fill-column: 100
End:
-->
16 changes: 16 additions & 0 deletions README.devel.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# Development guidelines

Please follow some simple rules for coding on CMIstark:
- keep the code consistent across the whole package!
- use git-flow (the tools and the concept)
- consistently use two empty lines between functions/methods and three empty
lines above a class



<!-- Put Emacs local variables into HTML comment
Local Variables:
coding: utf-8
fill-column: 80
End:
-->
29 changes: 27 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,27 @@
# Classical-Alignment
Classical Alignment of Molecules and Nanorods
# Classical-physics simulations of laser alignment

Classical-mechanics simulations of the rotational dynamics of rigid molecules
and nanoparticles in laser-electric fields.

See the files in `examples/` for a start.

## Installation


## Documentation


## Citation

When you use this program in scientific work, please cite it as Muhamed Amin,
Jean-Michel Hartmann, Amit K. Samanta, Jochen Küpper, "Laser-induced alignment
of nanoparticles and macromolecules for single-particle-imaging applications",
[arXiv:2306.05870](https://arxiv.org/abs/2306.05870)


<!-- Put Emacs local variables into HTML comment
Local Variables:
coding: utf-8
fill-column: 80
End:
-->
17 changes: 17 additions & 0 deletions cmiclassirot/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# -*- coding: utf-8; fill-column: 120; truncate-lines: t -*-
#
# Copyright (C) 2020 Jochen Küpper <[email protected]>
#
# This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public
# License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later
# version.
#
# If you use this programm for scientific work, you must correctly reference it; see LICENSE file for details.
#
# This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied
# warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License along with this program. If not, see
# <http://www.gnu.org/licenses/>.

__author__ = "Jochen Küpper <[email protected]>"
95 changes: 95 additions & 0 deletions cmiclassirot/field.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@
# -*- coding: utf-8; fill-column: 100 -*-
#
# This file is part of CMIclassirot -- classical-physics rotational molecular-dynamics simulations
#
# This program is free software: you can redistribute it and/or modify it under the terms of the GNU
# General Public License as published by the Free Software Foundation, either version 3 of the
# License, or (at your option) any later version.
#
# If you use this programm for scientific work, you must correctly reference it; see LICENSE file
# for details.
#
# This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without
# even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
# General Public License for more details.
#
# You should have received a copy of the GNU General Public License along with this program. If not,
# see <http://www.gnu.org/licenses/>.

import numpy as np
from scipy import interpolate
from scipy.constants import c, epsilon_0
from pyquaternion import Quaternion

class Field(object):
"""Electric field class
For the beginning, this only implements a simple Gaussian pulse (in field strengths!) centered
at t=0 and along `Z`.
.. todo:: Keep in mind that we want to be able to represent elliptically polaerized field by their envelope.
"""

def __init__(self, amplitude=1.e15, sigma=1.e-9, mean=5.e-9,
intensity=True, filename=None, dc=None):
self.amplitude = amplitude
self.sigma = sigma
self.Ez = np.array([0., 0., 1.])
self.from_file = None
self.intensity = intensity
self.mu = mean
self.dc = dc
if filename is not None:
f = open(filename)
E=[]
t=[]
for i in f:
token = i.split()
t.append(float(token[0]))
E.append(float(token[1]))
t = np.array(t)
E = np.array(E)
self.from_file = interpolate.interp1d(t,E)

def __call__(self, t):
"""Field at time t
:return: Field vector at time
"""
if self.dc is not None:
if t > self.dc[0] and t < self.dc[1]:
return self.convert(self.dc[2])
else:
return 0

if self.from_file is None:
E = self.amplitude * np.exp(-0.5 * ((t-self.mu)/self.sigma)**2)
if self.intensity:
return self.convert(E)
else:
return E
else:
try:
E = 1.e16*self.from_file(t)
if self.intensity:
return self.convert(E)
else:
return E
except:
return 0.

def convert(self, I):
""" Converts intensity to electric field"""
return np.sqrt(2*I/(c * epsilon_0))

def rotate(self, quaternion=Quaternion()):
"""Rotate field
This is used in the actual propagation step, as it is easier/cheaper to rotate the field
than to rotate the molecule
:param rotation: Define the rotation to be applied to the field, as an :class:`Quarternion`
"""
return quaternion.rotate(self.Ez)
76 changes: 76 additions & 0 deletions cmiclassirot/postprocessing.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
# -*- coding: utf-8; fill-column: 100 -*-
#
# This file is part of CMIclassirot -- classical-physics rotational molecular-dynamics simulations
#
# This program is free software: you can redistribute it and/or modify it under the terms of the GNU
# General Public License as published by the Free Software Foundation, either version 3 of the
# License, or (at your option) any later version.
#
# If you use this programm for scientific work, you must correctly reference it; see LICENSE.md file
# for details.
#
# This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without
# even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
# General Public License for more details.
#
# You should have received a copy of the GNU General Public License along with this program. If not,
# see <http://www.gnu.org/licenses/>.


import numpy as np


class Expectation(object):
"""Calculate expectation values of a probability density function given as an :class:`Ensemble`
.. todo:: implement
"""

def __init__(self, Ensemble):
pass

def __call__(self):
pass


class cos2theta(Expectation):
pass


class cos2theta_2D(Expectation):
pass



class ProbabilityGraphics(object):
"""Create a graphical representation of a probability density function
This Object requires a (variable dimension) probability density function and provides various
graphical outputs, such as actual 3D images/VRML graphs, contour plots of projections, etc.
.. todo:: implement
"""

def __init__(self):
pass



class Projection(object):
"""Project a probability distribution onto a plane or line
This object takes a 3D PDF and creates a lower-dimension PDF by projection onto an arbitrary
plane or line.
.. todo:: Discuss how this blends into :class:`Ensemble` and the funtionality in this file: For
instance, will we just create a new Ensemble with certain restrictions or in fact create an
independent data structure?
.. todo:: implement
"""

def __init__(self):
pass
Loading

0 comments on commit 847d919

Please sign in to comment.