Skip to content

Commit

Permalink
Merge pull request #11 from PyCOMPLETE/release
Browse files Browse the repository at this point in the history
New generators/matchors
  • Loading branch information
Stefannn committed Jun 24, 2015
2 parents 2570e45 + f579b02 commit e99b84b
Show file tree
Hide file tree
Showing 29 changed files with 1,224 additions and 1,352 deletions.
817 changes: 319 additions & 498 deletions particles/generators.py

Large diffs are not rendered by default.

115 changes: 27 additions & 88 deletions testing/interactive-tests/ApertureNLossesTest.ipynb

Large diffs are not rendered by default.

26 changes: 21 additions & 5 deletions testing/interactive-tests/DetunersCythonTest.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
},
{
"cell_type": "code",
"execution_count": 11,
"execution_count": 2,
"metadata": {
"collapsed": false
},
Expand All @@ -24,9 +24,25 @@
"name": "stdout",
"output_type": "stream",
"text": [
"PyHEADTAIL v1.2.0-153-gbc0ea69a06-dirty\n",
"\n",
"\n",
"No module named PySussix\n",
"trying PySUSSIX...\n"
]
},
{
"ename": "ImportError",
"evalue": "dlopen(../../../PySUSSIX/pysussix.so, 2): Library not loaded: /usr/local/lib/gcc/4.9/libgfortran.3.dylib\n Referenced from: /Users/stefan/CERN/PySUSSIX/PySussix.so\n Reason: image not found",
"output_type": "error",
"traceback": [
"\u001b[0;31m---------------------------------------------------------------------------\u001b[0m",
"\u001b[0;31mImportError\u001b[0m Traceback (most recent call last)",
"\u001b[0;32m<ipython-input-2-cbc2a4e5dbb8>\u001b[0m in \u001b[0;36m<module>\u001b[0;34m()\u001b[0m\n\u001b[1;32m 12\u001b[0m \u001b[0;32mprint\u001b[0m \u001b[0mem\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 13\u001b[0m \u001b[0;32mprint\u001b[0m \u001b[0;34m(\u001b[0m\u001b[0;34m'trying PySUSSIX...'\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m---> 14\u001b[0;31m \u001b[0;32mfrom\u001b[0m \u001b[0mPySUSSIX\u001b[0m \u001b[0;32mimport\u001b[0m \u001b[0mSussix\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m 15\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n",
"\u001b[0;32m/Users/stefan/CERN/PySUSSIX/__init__.py\u001b[0m in \u001b[0;36m<module>\u001b[0;34m()\u001b[0m\n\u001b[0;32m----> 1\u001b[0;31m \u001b[0;32mfrom\u001b[0m \u001b[0mPySussix\u001b[0m \u001b[0;32mimport\u001b[0m \u001b[0;34m*\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m",
"\u001b[0;32m/Users/stefan/CERN/PySUSSIX/PySussix.py\u001b[0m in \u001b[0;36m<module>\u001b[0;34m()\u001b[0m\n\u001b[1;32m 24\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 25\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m---> 26\u001b[0;31m \u001b[0;32mimport\u001b[0m \u001b[0mpysussix\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m 27\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 28\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n",
"\u001b[0;31mImportError\u001b[0m: dlopen(../../../PySUSSIX/pysussix.so, 2): Library not loaded: /usr/local/lib/gcc/4.9/libgfortran.3.dylib\n Referenced from: /Users/stefan/CERN/PySUSSIX/PySussix.so\n Reason: image not found"
]
}
],
"source": [
Expand All @@ -49,7 +65,7 @@
},
{
"cell_type": "code",
"execution_count": 12,
"execution_count": null,
"metadata": {
"collapsed": false
},
Expand Down Expand Up @@ -130,12 +146,12 @@
" epsn_y = 3.75e-6 # [m rad]\n",
" epsn_z = 4 * np.pi * sigma_z**2 * p0 / (beta_z * e)\n",
" \n",
" bunch = generators.Gaussian6DTwiss(\n",
" bunch = generators.generate_Gaussian6DTwiss(\n",
" macroparticlenumber=n_macroparticles, intensity=intensity, charge=e,\n",
" gamma=gamma, mass=m_p, circumference=C,\n",
" alpha_x=alpha_x, beta_x=beta_x, epsn_x=epsn_x,\n",
" alpha_y=alpha_y, beta_y=beta_y, epsn_y=epsn_y,\n",
" beta_z=beta_z, epsn_z=epsn_z).generate()\n",
" beta_z=beta_z, epsn_z=epsn_z)\n",
" #print bunch.sigma_z()\n",
"\n",
" return bunch"
Expand Down Expand Up @@ -348,7 +364,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython2",
"version": "2.7.9"
"version": "2.7.10"
}
},
"nbformat": 4,
Expand Down
6 changes: 3 additions & 3 deletions testing/interactive-tests/DetunersTest.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -129,12 +129,12 @@
" epsn_y = 3.75e-6 # [m rad]\n",
" epsn_z = 4 * np.pi * sigma_z**2 * p0 / (beta_z * e)\n",
" \n",
" bunch = generators.Gaussian6DTwiss(\n",
" bunch = generators.generate_Gaussian6DTwiss(\n",
" macroparticlenumber=n_macroparticles, intensity=intensity, charge=e,\n",
" gamma=gamma, mass=m_p, circumference=C,\n",
" alpha_x=alpha_x, beta_x=beta_x, epsn_x=epsn_x,\n",
" alpha_y=alpha_y, beta_y=beta_y, epsn_y=epsn_y,\n",
" beta_z=beta_z, epsn_z=epsn_z).generate()\n",
" beta_z=beta_z, epsn_z=epsn_z)\n",
" #print bunch.sigma_z()\n",
"\n",
" return bunch"
Expand Down Expand Up @@ -376,7 +376,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython2",
"version": "2.7.9"
"version": "2.7.10"
}
},
"nbformat": 4,
Expand Down
593 changes: 388 additions & 205 deletions testing/interactive-tests/GeneratorTest.ipynb

Large diffs are not rendered by default.

29 changes: 20 additions & 9 deletions testing/interactive-tests/MonitorTest.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
"name": "stdout",
"output_type": "stream",
"text": [
"PyHEADTAIL v1.2.0-122-g056083c437-dirty\n",
"PyHEADTAIL v1.2.0-153-gbc0ea69a06-dirty\n",
"\n",
"\n"
]
Expand All @@ -45,7 +45,7 @@
},
{
"cell_type": "code",
"execution_count": 3,
"execution_count": 7,
"metadata": {
"collapsed": false
},
Expand Down Expand Up @@ -130,20 +130,20 @@
" epsn_y = 3.75e-6 # [m rad]\n",
" epsn_z = 4 * np.pi * sigma_z**2 * p0 / (beta_z * e) # WITH OR WITHOUT 4 PIjQuery202047649151738733053_1414145430832?\n",
" \n",
" bunch = generators.Gaussian6DTwiss(\n",
" bunch = generators.generate_Gaussian6DTwiss(\n",
" macroparticlenumber=n_macroparticles, intensity=intensity, charge=e,\n",
" gamma=gamma, mass=m_p, circumference=C,\n",
" alpha_x=alpha_x, beta_x=beta_x, epsn_x=epsn_x,\n",
" alpha_y=alpha_y, beta_y=beta_y, epsn_y=epsn_y,\n",
" beta_z=beta_z, epsn_z=epsn_z).generate()\n",
" beta_z=beta_z, epsn_z=epsn_z)\n",
" print bunch.sigma_z()\n",
" \n",
" return bunch"
]
},
{
"cell_type": "code",
"execution_count": 4,
"execution_count": 8,
"metadata": {
"collapsed": false
},
Expand Down Expand Up @@ -177,7 +177,7 @@
},
{
"cell_type": "code",
"execution_count": 5,
"execution_count": 9,
"metadata": {
"collapsed": false
},
Expand All @@ -197,7 +197,7 @@
},
{
"cell_type": "code",
"execution_count": 6,
"execution_count": 10,
"metadata": {
"collapsed": false
},
Expand All @@ -206,7 +206,18 @@
"name": "stdout",
"output_type": "stream",
"text": [
"0.0621143131729\n"
"0.0598522977141\n"
]
},
{
"ename": "KeyboardInterrupt",
"evalue": "",
"output_type": "error",
"traceback": [
"\u001b[0;31m---------------------------------------------------------------------------\u001b[0m",
"\u001b[0;31mKeyboardInterrupt\u001b[0m Traceback (most recent call last)",
"\u001b[0;32m<ipython-input-10-39c3aff5b0d1>\u001b[0m in \u001b[0;36m<module>\u001b[0;34m()\u001b[0m\n\u001b[1;32m 30\u001b[0m \u001b[0mslice_monitor\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mdump\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mbunch\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 31\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m---> 32\u001b[0;31m \u001b[0mslice_set_pmon\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0mbunch\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mget_slices\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0munibin_slicer\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m 33\u001b[0m \u001b[0marrays_dict\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mupdate\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m{\u001b[0m\u001b[0;34m'slidx'\u001b[0m\u001b[0;34m:\u001b[0m \u001b[0mslice_set_pmon\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mslice_index_of_particle\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0;34m'zz'\u001b[0m\u001b[0;34m:\u001b[0m \u001b[0mbunch\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mz\u001b[0m\u001b[0;34m}\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 34\u001b[0m \u001b[0mparticle_monitor\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mdump\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mbunch\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0marrays_dict\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n",
"\u001b[0;31mKeyboardInterrupt\u001b[0m: "
]
}
],
Expand Down Expand Up @@ -290,7 +301,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython2",
"version": "2.7.9"
"version": "2.7.10"
}
},
"nbformat": 4,
Expand Down
32 changes: 21 additions & 11 deletions testing/interactive-tests/PyCUDA_longitudinal.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
"name": "stdout",
"output_type": "stream",
"text": [
"PyHEADTAIL v1.2.0-87-g2d87c2cf6b\n",
"PyHEADTAIL v1.3.0-10-ge651b0b162-dirty\n",
"\n",
"\n"
]
Expand All @@ -39,7 +39,7 @@
"from scipy.constants import c, e, m_p, epsilon_0\n",
"import numpy as np\n",
"\n",
"from PyHEADTAIL.particles.generators import Gaussian6D\n",
"from PyHEADTAIL.particles.generators import ParticleGenerator, gaussian2D, gaussian2D_asymmetrical\n",
"import PyHEADTAIL.trackers.simple_long_tracking as long_tracking\n",
"from PyHEADTAIL.particles.slicing import UniformBinSlicer\n",
"from PyHEADTAIL.spacecharge.spacecharge import LongSpaceCharge\n",
Expand Down Expand Up @@ -109,8 +109,10 @@
"outputs": [],
"source": [
"def make_bunch(macroparticlenumber):\n",
" return Gaussian6D(macroparticlenumber, intensity, e, m_p, circ, gamma, \n",
" sigx, sigxp, sigy, sigyp, sigz, sigdp).generate()\n",
" return ParticleGenerator(macroparticlenumber, intensity, e, m_p, circ, gamma,\n",
" distribution_x=gaussian2D_asymmetrical(sigx, sigxp),\n",
" distribution_y=gaussian2D_asymmetrical(sigy, sigyp),\n",
" distribution_z=gaussian2D_asymmetrical(sigz, sigdp)).generate()\n",
"\n",
"longitudinal_map = long_tracking.RFSystems(circ, h, V, phi, [alpha], gamma)\n",
"slicer = UniformBinSlicer(n_slices, n_sigma_z=3)\n",
Expand Down Expand Up @@ -170,7 +172,7 @@
"name": "stdout",
"output_type": "stream",
"text": [
"10 loops, best of 3: 131 ms per loop\n"
"10 loops, best of 3: 155 ms per loop\n"
]
}
],
Expand All @@ -189,7 +191,7 @@
"name": "stdout",
"output_type": "stream",
"text": [
"10 loops, best of 3: 58.6 ms per loop\n"
"10 loops, best of 3: 54.1 ms per loop\n"
]
}
],
Expand Down Expand Up @@ -217,6 +219,8 @@
"\n",
"bunch = make_bunch(macroparticlenumber)\n",
"\n",
"\n",
"\n",
"bunch.z = gpuarray.to_gpu(bunch.z.astype(np.float64))\n",
"bunch.dp = gpuarray.to_gpu(bunch.dp.astype(np.float64))\n",
"\n",
Expand Down Expand Up @@ -255,7 +259,7 @@
},
{
"cell_type": "code",
"execution_count": 13,
"execution_count": 10,
"metadata": {
"collapsed": false
},
Expand All @@ -264,17 +268,20 @@
"name": "stdout",
"output_type": "stream",
"text": [
"100 loops, best of 3: 17.3 ms per loop\n"
"The slowest run took 37.09 times longer than the fastest. This could mean that an intermediate result is being cached \n",
"1 loops, best of 3: 23.5 ms per loop\n"
]
}
],
"source": [
"bunch.x = gpuarray.to_gpu(bunch.x.astype(np.float64))\n",
"bunch.y = gpuarray.to_gpu(bunch.y.astype(np.float64))\n",
"%timeit longitudinal_map.track(bunch)"
]
},
{
"cell_type": "code",
"execution_count": 14,
"execution_count": 11,
"metadata": {
"collapsed": false
},
Expand All @@ -283,11 +290,14 @@
"name": "stdout",
"output_type": "stream",
"text": [
"100 loops, best of 3: 15.6 ms per loop\n"
"The slowest run took 8.28 times longer than the fastest. This could mean that an intermediate result is being cached \n",
"1 loops, best of 3: 45.6 ms per loop\n"
]
}
],
"source": [
"bunch.x = bunch.x.get() # cobra_functions cannot handle gpuarrays...\n",
"bunch.y = bunch.y.get() # cobra_functions cannot handle gpuarrays...\n",
"%timeit long_sc.track(bunch)"
]
},
Expand Down Expand Up @@ -317,7 +327,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython2",
"version": "2.7.9"
"version": "2.7.10"
}
},
"nbformat": 4,
Expand Down
100 changes: 47 additions & 53 deletions testing/interactive-tests/RFBucketHamiltonianDeformation.ipynb

Large diffs are not rendered by default.

27 changes: 21 additions & 6 deletions testing/interactive-tests/RFQTest.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
},
{
"cell_type": "code",
"execution_count": 3,
"execution_count": 2,
"metadata": {
"collapsed": false
},
Expand All @@ -24,8 +24,23 @@
"name": "stdout",
"output_type": "stream",
"text": [
"ERROR: This interactive test needs the PySussix module. Trying PySUSSIX...\n",
"PySUSSIX found\n"
"PyHEADTAIL v1.2.0-153-gbc0ea69a06-dirty\n",
"\n",
"\n",
"ERROR: This interactive test needs the PySussix module. Trying PySUSSIX...\n"
]
},
{
"ename": "ImportError",
"evalue": "dlopen(../../../PySUSSIX/pysussix.so, 2): Library not loaded: /usr/local/lib/gcc/4.9/libgfortran.3.dylib\n Referenced from: /Users/stefan/CERN/PySUSSIX/PySussix.so\n Reason: image not found",
"output_type": "error",
"traceback": [
"\u001b[0;31m---------------------------------------------------------------------------\u001b[0m",
"\u001b[0;31mImportError\u001b[0m Traceback (most recent call last)",
"\u001b[0;32m<ipython-input-2-862e12413d5c>\u001b[0m in \u001b[0;36m<module>\u001b[0;34m()\u001b[0m\n\u001b[1;32m 12\u001b[0m \u001b[0;32mexcept\u001b[0m \u001b[0mImportError\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 13\u001b[0m \u001b[0;32mprint\u001b[0m \u001b[0;34m(\u001b[0m\u001b[0;34m'ERROR: This interactive test needs the PySussix module. Trying PySUSSIX...'\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m---> 14\u001b[0;31m \u001b[0;32mfrom\u001b[0m \u001b[0mPySUSSIX\u001b[0m \u001b[0;32mimport\u001b[0m \u001b[0mSussix\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m 15\u001b[0m \u001b[0;32mprint\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m'PySUSSIX found'\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n",
"\u001b[0;32m/Users/stefan/CERN/PySUSSIX/__init__.py\u001b[0m in \u001b[0;36m<module>\u001b[0;34m()\u001b[0m\n\u001b[0;32m----> 1\u001b[0;31m \u001b[0;32mfrom\u001b[0m \u001b[0mPySussix\u001b[0m \u001b[0;32mimport\u001b[0m \u001b[0;34m*\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m",
"\u001b[0;32m/Users/stefan/CERN/PySUSSIX/PySussix.py\u001b[0m in \u001b[0;36m<module>\u001b[0;34m()\u001b[0m\n\u001b[1;32m 24\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 25\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m---> 26\u001b[0;31m \u001b[0;32mimport\u001b[0m \u001b[0mpysussix\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m 27\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 28\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n",
"\u001b[0;31mImportError\u001b[0m: dlopen(../../../PySUSSIX/pysussix.so, 2): Library not loaded: /usr/local/lib/gcc/4.9/libgfortran.3.dylib\n Referenced from: /Users/stefan/CERN/PySUSSIX/PySussix.so\n Reason: image not found"
]
}
],
Expand Down Expand Up @@ -131,12 +146,12 @@
" epsn_y = 3.75e-6 # [m rad]\n",
" epsn_z = 4 * np.pi * sigma_z**2 * p0 / (beta_z * e) \n",
" \n",
" bunch = generators.Gaussian6DTwiss(\n",
" bunch = generators.generate_Gaussian6DTwiss(\n",
" macroparticlenumber=n_macroparticles, intensity=intensity, charge=e,\n",
" gamma=gamma, mass=m_p, circumference=C,\n",
" alpha_x=alpha_x, beta_x=beta_x, epsn_x=epsn_x,\n",
" alpha_y=alpha_y, beta_y=beta_y, epsn_y=epsn_y,\n",
" beta_z=beta_z, epsn_z=epsn_z).generate()\n",
" beta_z=beta_z, epsn_z=epsn_z)\n",
" \n",
" return bunch"
]
Expand Down Expand Up @@ -358,7 +373,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython2",
"version": "2.7.9"
"version": "2.7.10"
}
},
"nbformat": 4,
Expand Down
Loading

0 comments on commit e99b84b

Please sign in to comment.