Jekyll2016-10-20T13:05:02+00:00https://pycav.github.io/PyCavPyCav is developing Python tools for teaching Physics at the University of CambridgeNumerical Techniques2016-09-06T11:13:00+00:002016-09-06T11:13:00+00:00https://pycav.github.io/numerical-techniques<p>One of the advantages of Python is the selection of libraries which greatly simplify complex tasks. For example NumPy allows for matrix multiplication and other vector operations as well as more complex operations such as eigenvalue evaluation which for other languages may require additional set up (such as workspaces in fortran).</p>
<p>For numerical techniques for solving ODEs, SciPy provides the general <a href="http://docs.scipy.org/doc/scipy/reference/generated/scipy.integrate.odeint.html">odeint function</a> which can integrate a system of differential equations in a single line. In the background it calls from the fortran odepack, thus making it quick but only requires minimal boilerplate to call (unlike GSL as used in the current C++ course).</p>
<p>Many numerical algorithms, namely finite difference methods, require looping over grid points. In Python this would be excessively slow (<a href="https://youtu.be/EEUXKG97YRw?t=4m31s">video showing looping comparison with explanation</a>), however using the NumPy library C/C++ and fortran operations can speed up such tasks by pushing repeated operations into compiled code (also shown in video). Now loops can be replaced by slicing and indexing, all done within a single line. Although not strictly faster than a low-level language equivalent, the time saved in writing the Python version using NumPy to replace the loops can make for an efficient program.</p>
<p>From the students perspective, the simplicity of these Pythonified algorithms allows for more to be investigated. For example, rather than spending time trying to figure out how to handle the output of a Fast Fourier Transform, NumPy and SciPy provide the fftshift function to place the zero frequency at the origin. This would give students more time to investigate complex diffraction patterns and think about the Physics while using the code as a tool.</p>
<p>Hopefully the reduced debugging and writing time would allow for different physical situations and therefore different numerical algorithms to be used. This would show that there is more to life than RK4.</p>
<p>Below we shall point to some Demo notebooks using particular numerical algorithms as well as resources providing explanation of the technique</p>
<h2 id="algorithms-and-resources">Algorithms and Resources</h2>
<h3 id="from-scipy-and-numpy">From SciPy and NumPy:</h3>
<table>
<tbody>
<tr>
<td>scipy.odeint</td>
<td><a href="http://nbviewer.jupyter.org/github/PyCav/Demos/blob/master/Dynamics/gyroscope.ipynb">Gyroscope</a></td>
<td><a href="http://docs.scipy.org/doc/scipy/reference/generated/scipy.integrate.odeint.html">odeint</a></td>
</tr>
<tr>
<td>scipy.quad</td>
<td><a href="http://nbviewer.jupyter.org/github/PyCav/Investigations/blob/master/LongProblems/perturbation_theory_solutions.ipynb">Perturbation Theory</a></td>
<td><a href="http://docs.scipy.org/doc/scipy/reference/generated/scipy.integrate.quad.html">quad</a></td>
</tr>
<tr>
<td>numpy.eig</td>
<td><a href="http://nbviewer.jupyter.org/github/PyCav/Demos/blob/master/Eigensystems/LinearChain.ipynb">Linear Chain</a></td>
<td><a href="http://docs.scipy.org/doc/numpy/reference/generated/numpy.linalg.eig.html">eig</a></td>
</tr>
</tbody>
</table>
<h3 id="established-numerical-techniques-written-in-python">Established Numerical Techniques written in Python:</h3>
<table>
<tbody>
<tr>
<td>Lax & Lax-Wendroff</td>
<td><a href="http://nbviewer.jupyter.org/github/PyCav/Demos/blob/master/WavesAndOscillations/numerical_wave_equation.ipynb">Wave Equation</a></td>
<td>Numerical Recipes: The Art of Scientific Computing Book, <a href="http://www.aei.mpg.de/~rezzolla/lnotes/Evolution_Pdes/evolution_pdes_lnotes.pdf">Solving PDEs numerically</a> & <a href="http://homepage.univie.ac.at/franz.vesely/cp_tut/nol2h/new/c5pd_s1ih.html">Algorithm summaries in 1D and 2D</a></td>
</tr>
<tr>
<td>Split Step Fourier method</td>
<td><a href="http://nbviewer.jupyter.org/github/PyCav/Demos/blob/master/QuantumMechanics/1D_reflectionless_potential.ipynb">Reflectionless Potential</a></td>
<td><a href="https://jakevdp.github.io/blog/2012/09/05/quantum-python/">Quantum Python</a> & <a href="https://en.wikipedia.org/wiki/Split-step_method">Split-step wiki</a></td>
</tr>
<tr>
<td>Shooting method</td>
<td><a href="http://nbviewer.jupyter.org/github/PyCav/Investigations/blob/master/LongProblems/shooting_method.ipynb">Finite Square Well</a></td>
<td><a href="http://www.fisica.uniud.it/~giannozz/Corsi/MQ/LectureNotes/mq-cap1.pdf">Numerov Method</a></td>
</tr>
<tr>
<td>Monte-Carlo</td>
<td><a href="http://nbviewer.jupyter.org/github/PyCav/Demos/blob/master/Statistics/Bateman_Eqn.ipynb">Bateman Equation</a></td>
<td><a href="https://en.wikipedia.org/wiki/Monte_Carlo_method">Monte Carlo wiki</a> (see also Ising model notebooks for Metropolis algorithm)</td>
</tr>
<tr>
<td>Lattice Boltzmann</td>
<td><a href="http://nbviewer.jupyter.org/github/PyCav/Demos/blob/master/FluidDynamics/LatticeBoltzmann.ipynb">Flow onto a barrier</a></td>
<td><a href="http://physics.weber.edu/schroeder/javacourse/LatticeBoltzmann.pdf">LBM</a></td>
</tr>
</tbody>
</table>
<p>and others</p>
<h3 id="custom-algorithms">Custom Algorithms:</h3>
<table>
<tbody>
<tr>
<td>Cherenkov Radiation</td>
<td><a href="http://nbviewer.jupyter.org/github/PyCav/Demos/blob/master/Electromagnetism/Cherenkov.ipynb">Notebook</a></td>
<td> </td>
</tr>
<tr>
<td>Light Ray Caustic</td>
<td><a href="http://nbviewer.jupyter.org/github/PyCav/Demos/blob/master/Optics/Caustics.ipynb">Caustic</a></td>
<td><a href="https://en.wikipedia.org/wiki/Ray_transfer_matrix_analysis">Ray Transfer Matrix Analysis</a> & <a href="http://pycav.readthedocs.io/en/latest/api/optics/index.html">PyCav Optics Docs</a></td>
</tr>
</tbody>
</table>aidancrillyOne of the advantages of Python is the selection of libraries which greatly simplify complex tasks. For example NumPy allows for matrix multiplication and other vector operations as well as more complex operations such as eigenvalue evaluation which for other languages may require additional set up (such as workspaces in fortran).
For numerical techniques for solving ODEs, SciPy provides the general odeint function which can integrate a system of differential equations in a single line. In the background it calls from the fortran odepack, thus making it quick but only requires minimal boilerplate to call (unlike GSL as used in the current C++ course).
Many numerical algorithms, namely finite difference methods, require looping over grid points. In Python this would be excessively slow (video showing looping comparison with explanation), however using the NumPy library C/C++ and fortran operations can speed up such tasks by pushing repeated operations into compiled code (also shown in video). Now loops can be replaced by slicing and indexing, all done within a single line. Although not strictly faster than a low-level language equivalent, the time saved in writing the Python version using NumPy to replace the loops can make for an efficient program.
From the students perspective, the simplicity of these Pythonified algorithms allows for more to be investigated. For example, rather than spending time trying to figure out how to handle the output of a Fast Fourier Transform, NumPy and SciPy provide the fftshift function to place the zero frequency at the origin. This would give students more time to investigate complex diffraction patterns and think about the Physics while using the code as a tool.
Hopefully the reduced debugging and writing time would allow for different physical situations and therefore different numerical algorithms to be used. This would show that there is more to life than RK4.
Below we shall point to some Demo notebooks using particular numerical algorithms as well as resources providing explanation of the technique
Algorithms and Resources
From SciPy and NumPy:
scipy.odeint
Gyroscope
odeint
scipy.quad
Perturbation Theory
quad
numpy.eig
Linear Chain
eig
Established Numerical Techniques written in Python:
Lax & Lax-Wendroff
Wave Equation
Numerical Recipes: The Art of Scientific Computing Book, Solving PDEs numerically & Algorithm summaries in 1D and 2D
Split Step Fourier method
Reflectionless Potential
Quantum Python & Split-step wiki
Shooting method
Finite Square Well
Numerov Method
Monte-Carlo
Bateman Equation
Monte Carlo wiki (see also Ising model notebooks for Metropolis algorithm)
Lattice Boltzmann
Flow onto a barrier
LBM
and others
Custom Algorithms:
Cherenkov Radiation
Notebook
Light Ray Caustic
Caustic
Ray Transfer Matrix Analysis & PyCav Optics DocsA PyCav Course2016-08-22T11:13:00+00:002016-08-22T11:13:00+00:00https://pycav.github.io/pycav-course<h1 id="introduction">Introduction</h1>
<p>As part of the PyCav project, the team drew upon their experiences of studying Computational Physics at the University of Cambridge in an endeavour to create a new <em>proof-of-concept</em> course centred around Python.</p>
<p>This blog post will outline our motivation for such a course, the course structure we adopted, the content of the course, a discussion of the outcome of the course development, the future work required, and a conclusion to tie the post together.</p>
<h1 id="motivation">Motivation</h1>
<p>The motivation for development of this course is best encapsulated in the <a href="http://pycav.org/pycav-manifesto/">PyCav Manifesto</a>.</p>
<p>As of August 2016, the Physics course at Cambridge does not have a Computational Physics course that was developed around Python.
Although, in fairness, the <a href="http://www.mrao.cam.ac.uk/~dfb/teaching/computationalphysics/">computational course</a> in Part II (the third year) has shifted its weight behind Python.
This represents a direct transition from C++ - perhaps closer to the truth, a translation therefrom. We felt that the consistency derived from working with one language in a course would help students transition to seeing the bigger picture after building confidence and maturity in programming.</p>
<p>One could argue that the Scientific Computing aspects of the (Physical) Natural Sciences Tripos (NST) are quite fragmented.
For example, in Part IA (the first year), one completes a standalone course in MATLAB.
A self-taught, standalone C++ course in Computational Physics is encountered, if one then proceeded to take the Physics B option in Part IB (the second year).
This in some regard, is a result of the flexibility provided by the level of choice available to students in the NST - which itself is highly desirable.
What is undesirable is that this compartmentalisation of teaching creates a horizontal learning environment; that is to say, one finds many occasions where one has to start close to square one, rather than building directly and consistently upon previous years experience. Of course, this is not an absolute rule. It is certainly true that the skill development throughout these courses extends the type of problems that an undergraduate student can tackle.
The PyCav team felt that a higher level of integration was desirable.
It was our belief that increased integration across year boundaries would improve feelings of relevance among students as well as providing opportunities for repetition and subsequent advancement of programming and scientific computing concepts.</p>
<p>Finally, we were motivated to use modern development tools without the hurdles that accompany more advanced software development practices. We are Physicists, after all. In part, this was influenced by attempting to reduce the ‘cognitive overload’ that undergraduates encounter when approaching the field. This decision was based upon our interpretation of discussion from <a href="http://arxiv.org/abs/1505.05425">this paper</a>.</p>
<p>We felt that it was desirable to start from scratch. Thus we created this hypothetical course, which we hope some keen individuals may attempt to learn from.</p>
<h1 id="structure">Structure</h1>
<p>Directly following from our motivation, the course is structured from Part IA to Part II; the Bachelor’s components of the course.</p>
<p>On top of this, we split the course into three streams. Each year, the learning focus would shift towards Scientific Computing as fluency increases. These streams are:</p>
<ul>
<li><em>Programming</em>: How to program in Python, using the features that the language provides. Additionally, this outlines some of the more abstract concepts associated with programming which are not scientific (at least, physically) in nature.</li>
<li><em>Scientific Computing</em>: This would use the skills learnt in the <em>Programming</em> stream to help students understand how to use Python to tackle scientific programming challenges.</li>
<li><em>Optional Components</em>: For students who want to learn more, this stream provides more challenging programming concepts (like OOP and Lambda expressions).</li>
</ul>
<p>Exercises for this course would be classified in the following way:</p>
<iframe src="http://docs.google.com/gview?url=https://github.com/PyCav/Investigations/raw/master/investigations_framework.pdf&embedded=true" style="width:400px; height:400px;" frameborder="0"></iframe>
<p>To balance the load for what is an already intense course, we suggest replacing some exercises on the example sheets for courses with shorter Python problems.</p>
<p>Additionally, we think that the <a href="https://github.com/PyCav/Demos">Demonstrations</a> that we have produced could be used in lectures. These would effectively be open source, allowing students to view the code for some physics examples. This is in eeping with the PyCav ethos of unification.</p>
<h1 id="content">Content</h1>
<p>You can view the course content on the <a href="https://github.com/PyCav/Course">Course GitHub</a>.</p>
<p>An outline of the course syllabus, as well as the divisions across year groups and content is presented in the table below. The Part II material, while it exists is currently distributed in the <a href="https://github.com/PyCav/Investigations">Investigations</a> repository. This is due to our focus on the earlier years which don’t have any Python teaching at all.</p>
<table>
<thead>
<tr>
<th> </th>
<th>Part IA</th>
<th>Part IB</th>
<th>Part II</th>
</tr>
</thead>
<tbody>
<tr>
<td><strong>Programming</strong></td>
<td><a href="http://nbviewer.jupyter.org/github/PyCav/Course/blob/master/IA/Lessons/1.1.Algorithms.ipynb">Algorithms</a></td>
<td><a href="http://nbviewer.jupyter.org/github/PyCav/Course/blob/master/IB/Lessons/2.1%20Advanced%20functions%20and%20loops.ipynb">Recap</a></td>
<td>Random Numbers</td>
</tr>
<tr>
<td> </td>
<td><a href="http://nbviewer.jupyter.org/github/PyCav/Course/blob/master/IA/Lessons/1.2.Variables.ipynb">Variables & Types</a></td>
<td><a href="http://nbviewer.jupyter.org/githu/PyCav/Course/blob/master/IB/Lessons/2.2%20Advanced%20algorithms.ipynb">Adv. Algorithms</a></td>
<td>Floating Point Numbers</td>
</tr>
<tr>
<td> </td>
<td><a href="http://nbviewer.jupyter.org/github/PyCav/Course/blob/master/IA/Lessons/1.3.Control%20Flow.ipynb">Lists & Loops</a></td>
<td><a href="http://nbviewer.jupyter.org/github/PyCav/Course/blob/master/IB/Lessons/2.4%20Make%20your%20own%20library.ipynb">Modules</a></td>
<td>Errors</td>
</tr>
<tr>
<td> </td>
<td><a href="http://nbviewer.jupyter.org/github/PyCav/Course/blob/master/IA/Lessons/1.4.Functions%20Methods.ipynb">Functions</a> & <a href="http://nbviewer.jupyter.org/github/PyCav/Course/blob/master/IA/Lessons/1.5.%20Libraries.ipynb">Libraries</a></td>
<td><a href="http://nbviewer.jupyter.org/github/PyCav/Course/blob/master/IB/Lessons/2.3%20OOp.ipynb">Introduction to OOP</a></td>
<td>Recursion</td>
</tr>
<tr>
<td><strong>Scientific Computing</strong></td>
<td><a href="http://nbviewer.jupyter.org/github/PyCav/Course/blob/master/IA/SciComp/Euler%20method.ipynb">Euler Step</a></td>
<td>Further Simulation Techniques</td>
<td>ODEs</td>
</tr>
<tr>
<td> </td>
<td><a href="http://nbviewer.jupyter.org/github/PyCav/Course/blob/master/IA/SciComp/plot_ex2.ipynb">Plotting</a></td>
<td>Singular Value Decomposition</td>
<td>PDEs</td>
</tr>
<tr>
<td> </td>
<td><a href="http://nbviewer.jupyter.org/github/PyCav/Course/blob/master/IA/SciComp/int_ex.ipynb">Integration by the Trapezium Rule</a></td>
<td>Eigenanalysis</td>
<td>FFT</td>
</tr>
<tr>
<td> </td>
<td><a href="http://nbviewer.jupyter.org/github/PyCav/Course/blob/master/IA/SciComp/importingdata.ipynb">Importing & Analysing Data</a></td>
<td>Monecarlo Methods</td>
<td>Additional Signal Processing</td>
</tr>
<tr>
<td> </td>
<td> </td>
<td>Central Limit Theorem</td>
<td> </td>
</tr>
<tr>
<td><strong>Optional</strong></td>
<td><a href="http://nbviewer.jupyter.org/github/PyCav/Course/blob/master/IA/Extra/GoodPractices.ipynb">Comments & Coding Style</a></td>
<td><a href="http://nbviewer.jupyter.org/github/PyCav/Course/blob/master/IB/Extra/2.Optional%20-%20Lambdas.ipynb">$\lambda$ functions</a></td>
<td>Alternative OSes & Hardware</td>
</tr>
<tr>
<td> </td>
<td> </td>
<td><a href="http://nbviewer.jupyter.org/github/PyCav/Course/blob/master/IB/Extra/2.Optional-%20Common%20mistakes%20in%20python.ipynb">Gotchas</a></td>
<td>Optimisation/Cython</td>
</tr>
<tr>
<td> </td>
<td> </td>
<td>Animations</td>
<td> </td>
</tr>
<tr>
<td> </td>
<td> </td>
<td>Debugging</td>
<td> </td>
</tr>
</tbody>
</table>
<h1 id="discussion">Discussion</h1>
<p>The proposed course structure does go someway towards resolving some of the issues mentioned in the motivation. Where applicable, lessons were designed with a ‘Theory’ followed by ‘Practice’ section. We think that viewing examples first, followed by exercises that step to one side of the material are useful for easing students into new concepts.</p>
<p>As for the content, the early programming courses aim to introduce people to thinking about processes, a key step in translating thoughts and intentions into programs. The OOP lesson aims to introduce the concept to students while keeping it relevant for a physics student.</p>
<p>An area where we agreed that we were deficient is that of data analysis. Thus we think that more focus could be placed on teaching students how to use data analysis packages such as ROOT which are currently being used by modern institutions (namely CERN). Additionally, it would be apt for Python to be used in data analysis in the Part IB and Part II labs. The current structure of experimental classes is largely the domain of the Heads of Class and thus would require a joint decision to move in that direction. Currently, it seems, Excel and MATLAB are the most popular software implementations in the Teaching Labs at the Cavendish and it would requirethe establishment and overcoming a transitionary period, which is easier said than done. On top of this, the presiding language agnosticism of the Part II labs affords some students the flexibility to conduct experiments as they see fit, which is worth considering.</p>
<h1 id="future-work">Future Work</h1>
<p><em>It doesn’t matter how beautiful your theory is, it doesn’t matter how smart you are. If it doesn’t agree with experiment, it’s wrong.</em> <br /> R.P. Feynman.</p>
<p>Hopefully without sounding too much like a EULA, we can note that this course is <strong>untested</strong>. We had many thoughts about what was right and what was wrong about the way we were taught computational physics. It would not be in keeping with the exercise of our critical capacity to suggest that it is the <em>right</em> way to teach computational physics. Good practice requires good evidence. Thus, the future of such a course lies in testing it, gathering meaningful feedback from those who participate in it, and measuring whether or not it improves the understanding of scientific computation in the NST.</p>
<p>A starting point for this may be to draw upon the UCL experience in their 2016 paper on the matter (referenced above).</p>
<p>In terms of the development of the course (as opposed to the above, which concerns measurement of effectiveness), pursuing better integration into the degree course would be desirable. So far we have only created a course with some content but haven’t worried about questions like:</p>
<ul>
<li>Who is teaching it?</li>
<li>When are they teaching it?</li>
<li>How are they teaching it?</li>
</ul>
<p>Engaging with lecturers and students to further develop an enjoyable course would be ideal. To an extent, this is already happening.</p>
<p>Testing will also need to be done with the <em>nbgrader</em> software. The backend was setup and configured for use with the University of Cambridge auth systems - apart from this, no rigorous testing was conducted.</p>
<p>More work on Data Analysis would be highly desirable.</p>niallmcconvilleIntroductionAnimations and Interactive Plots2016-08-11T12:13:00+00:002016-08-11T12:13:00+00:00https://pycav.github.io/nbviewer-animations-plots<p>Jupyter Notebooks can used to run code within the <a href="https://nile.pycav.org/">server</a> or locally; however they can also be used to present the output of the code.
This could include figures, animations, parameter estimations etc. along with the markdown comments and LaTeX equations. Running the code to produce these when
presenting could include unwanted setup and delay. However the notebooks, along with the desired material, can be viewed in an internet browser using
<a href="https://nbviewer.jupyter.org">NBViewer</a> without the need to run any code.</p>
<p>Some examples produced from the PyCav Project, click the images to view the demonstrations:</p>
<figure>
<center><a href="https://nbviewer.jupyter.org/github/PyCav/Demos/blob/master/Dynamics/gyroscope.ipynb">
<img src="/assets/images/nbviewerthumbs/deadoralive.png" alt="Classical Dynamics: Symmetric Spinning Top" />
</a></center>
<figcaption>
Classical Dynamics: Symmetric Spinning Top
</figcaption>
</figure>
<figure>
<center><a href="https://nbviewer.jupyter.org/github/PyCav/Demos/blob/master/Electromagnetism/Cherenkov.ipynb">
<img src="/assets/images/nbviewerthumbs/cherenkov.png" alt="Electromagnetism: Cherenkov Radiation" />
</a></center>
<figcaption>
Electromagnetism: Cherenkov Radiation
</figcaption>
</figure>
<figure>
<center><a href="https://nbviewer.jupyter.org/github/PyCav/Demos/blob/master/WavesAndOscillations/FoldyLax.ipynb">
<img src="/assets/images/nbviewerthumbs/foldy_lax.png" alt="Steady State Scattering: Foldy Lax" />
</a></center>
<figcaption>
Steady State Scattering: Foldy Lax
</figcaption>
</figure>
<figure>
<center><a href="https://nbviewer.jupyter.org/github/PyCav/Demos/blob/master/FluidDynamics/LatticeBoltzmann.ipynb">
<img src="/assets/images/nbviewerthumbs/latticeboltzmann.png" alt="Fluid Dynamics: Flow onto a barrier via Lattice Boltzmann Method" />
</a></center>
<figcaption>
Fluid Dynamics: Flow onto a barrier via Lattice Boltzmann Method
</figcaption>
</figure>
<figure>
<center><a href="https://nbviewer.jupyter.org/github/PyCav/Demos/blob/master/WavesAndOscillations/numerical_wave_equation.ipynb">
<img src="/assets/images/nbviewerthumbs/numerical_wave_equation.png" alt="Wave Equation: 1D & 2D" />
</a></center>
<figcaption>
Wave Equation: 1D & 2D
</figcaption>
</figure>
<figure>
<center><a href="https://nbviewer.jupyter.org/github/PyCav/Investigations/blob/master/LongProblems/shooting_method.ipynb">
<img src="/assets/images/nbviewerthumbs/shooting_method.png" alt="Time-Independent QM: Shooting Method for Finite Square Well" />
</a></center>
<figcaption>
Time-Independent QM: Shooting Method for Finite Square Well
</figcaption>
</figure>
<figure>
<center><a href="https://nbviewer.jupyter.org/github/PyCav/Demos/blob/master/QuantumMechanics/alpha_decay.ipynb">
<img src="/assets/images/nbviewerthumbs/split_step_schroedinger.png" alt="Time-Dependent QM: 1D Barriers & Harmonic Potentials" />
</a></center>
<figcaption>
Time-Dependent QM: 1D Alpha Decay
</figcaption>
</figure>
<p>A tutorial on how to use the PyCav display module can be found <a href="https://nbviewer.jupyter.org/github/PyCav/Demos/blob/master/Animation/Inline_animation_tutorial.ipynb">here</a>.</p>
<p>Animations are produced using matplotlib but plots can be produced by both matplotlib and bokeh. An advantage of bokeh is that when the notebook
is viewed in the browser it allows for the plot tools such as zoom to be used, while matplotlib does not. However its documentation is not as extensive.</p>aidancrillyJupyter Notebooks can used to run code within the server or locally; however they can also be used to present the output of the code.
This could include figures, animations, parameter estimations etc. along with the markdown comments and LaTeX equations. Running the code to produce these when
presenting could include unwanted setup and delay. However the notebooks, along with the desired material, can be viewed in an internet browser using
NBViewer without the need to run any code.The PyCav Library2016-08-05T10:44:00+00:002016-08-05T10:44:00+00:00https://pycav.github.io/the-pycav-library<script type="text/x-mathjax-config">
MathJax.Hub.Config({tex2jax: {inlineMath: [['$','$'], ['\\(','\\)']]}});
</script>
<script type="text/javascript" async="" src="https://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS_CHTML">
</script>
<p>The PyCav library consists of an ever-growing number of modules that proved useful in creating demonstrations, which any user could use through a simple set of functions and objects. It allows for easy creation and visualization of simulations ranging from a number of classical particles in a box to solving the time dependent Schrodinger equation.</p>
<p>The library has been made readily available on PyPI in the hopes that students and others can use it readily, making computer simulations an integral part of the learning experience.</p>
<p>To install the PyCav Library, one can use the pip install command in Terminal/Command Line:</p>
<div class="highlighter-rouge"><pre class="highlight"><code>pip install pycav
</code></pre>
</div>
<p>The project is also open sourced on <a href="https://github.com/PyCav/PyCav-Library," title="PyCav library on GitHub">GitHub</a>, and we hope that the more capable students will not only use, but also start contributing to the library.</p>
<h3 id="a-quick-tour-of-pycav">A Quick Tour of PyCav</h3>
<h4 id="documentation">Documentation</h4>
<p>In depth documentation of PyCav’s usage and implementation can be found <a href="http://pycav.readthedocs.io/en/latest/api/index.html">here</a></p>
<h4 id="classical-mechanicshttppycavreadthedocsioenlatestapimechanicsindexhtml"><a href="http://pycav.readthedocs.io/en/latest/api/mechanics/index.html">Classical Mechanics</a></h4>
<p>This module contains particle, which can interact through user-defined force laws, and spring objects which can connect particle objects</p>
<p>This allows a large number of dynamical systems to be simulated e.g. resonance and gravitational interactions</p>
<p>Large numbers of particles can be used to model a gas, ideal or interacting.</p>
<h4 id="quantum-mechanicshttppycavreadthedocsioenlatestapiquantumindexhtml-time-independent"><a href="http://pycav.readthedocs.io/en/latest/api/quantum/index.html">Quantum Mechanics</a> (Time Independent)</h4>
<p>This module includes the capability to:</p>
<ol>
<li>
<p>Find the stationary states and energy eigenvalues of a potential via the shooting method</p>
</li>
<li>
<p>First order time independent perturbation theory for known unperturbed wavefunctions and eigenvalues</p>
</li>
<li>
<p>Plot the unperturbed and perturbed energy levels along the perturbed potential</p>
</li>
</ol>
<h4 id="partial-differential-equationshttppycavreadthedocsioenlatestapipdeindexhtml"><a href="http://pycav.readthedocs.io/en/latest/api/pde/index.html">Partial Differential Equations</a></h4>
<p>Methods for solving the following PDEs numerically are included in the pde module:</p>
<ol>
<li>
<p>Wave Equation - \( \ddot{\psi} = c^2 \nabla^2 \psi \)</p>
</li>
<li>
<p>Heat Equation - \( \dot{\psi} = D \nabla^2 \psi \)</p>
</li>
<li>
<p>Time-Dependent Schrödinger Equation - \( \hat{H} \psi = i \hbar \dot{\psi} \)</p>
</li>
</ol>
<h4 id="geometric-opticshttppycavreadthedocsioenlatestapiopticsindexhtml"><a href="http://pycav.readthedocs.io/en/latest/api/optics/index.html">Geometric Optics</a></h4>
<p>Contains ray object for observing refraction into another medium. Other functions included allow to observe caustics caused by refraction</p>aidancrillyThe PyCav manifesto2016-08-04T22:52:00+00:002016-08-04T22:52:00+00:00https://pycav.github.io/pycav-manifesto<p><em>In order to give a bit of background on the origins of the PyCav project, I’m attaching the application that John and I made back in January to the <a href="http://www.cctl.cam.ac.uk/support-and-training/funding/teaching-and-learning-innovation-fund">Teaching and Learning Innovation Fund</a>.</em></p>
<blockquote>
<p>The goals of <strong>PyCav</strong> are:</p>
</blockquote>
<blockquote>
<ol>
<li>To put the one or two rather powerful computers that a typical undergraduate carries with them into service in the teaching and <em>visualization</em> of key physics concepts.</li>
<li>To dramatically raise the computer literacy of our undergraduates.</li>
</ol>
</blockquote>
<blockquote>
<p>Physics research is a quantitative discipline that relies heavily on computational tools to run experiments, gather and analyze data, and build theoretical models. The benefits of computation to the <em>teaching</em> of physics in Cambridge are, in our opinion, equally great, but at present only partially realized.</p>
</blockquote>
<blockquote>
<p>Because physicists have historically been early adopters of new technology, our current computational curriculum is fragmented across multiple platforms, so that a typical student does not achieve fluency in any one language. This creates a vicious circle in which lecturers do not feel empowered or motivated to add more computation to their courses, and students lack enthusiasm for what will almost certainly be an important part of their later careers, whether in business, industry, or academia.</p>
</blockquote>
<blockquote>
<p><strong>PyCav</strong> will address this need by developing a coherent cutting edge curriculum for computational physics. We propose to integrate computational physics into the existing physics lecture courses, and use a modern computing language (Python), which has the benefits of openness, wide adoption in physics research and commercial environments, graphical richness, and rapid development using high-quality existing libraries.</p>
</blockquote>
<blockquote>
<p><strong>PyCav</strong> will consist of four streams, to develop:</p>
</blockquote>
<blockquote>
<ol>
<li>A set of computational physics investigations related to some of our major Physics lecture courses, which allow our students to explore and visualize complex physical phenomena beyond the analytic examples given in lectures. We will initially target examples for our own lectures courses in Optics (Richer) and Theoretical Physics (Lamacraft).</li>
</ol>
</blockquote>
<blockquote>
<ol>
<li>Dynamic web pages which host these problems, and provide solutions or hints for student self-evaluation. We will also investigate methods for automatic code validation, as used in the Computer Science Tripos.</li>
</ol>
</blockquote>
<blockquote>
<ol>
<li>Lecture “demonstrations” in Python for a small number of lecture courses.</li>
</ol>
</blockquote>
<blockquote>
<ol>
<li>Python tools for data manipulation, data analysis and plotting in the undergraduate practical classes.</li>
</ol>
</blockquote>
<blockquote>
<p>TLIF funding will be used to pay four summer students, each assigned to one of the above streams. Current or recently graduated physics students are the ideal staff for this project, because they will bring their own experience of the undergraduate course, ensuring that materials are developed at the right level. A high level of physics understanding is key to the success of the project, and we expect several of our own Part II and III students, and perhaps some from Computer Science, will be very interested in these summer jobs.</p>
</blockquote>
<blockquote>
<p>The PIs will evaluate and choose the best Python distribution and platform for our teaching. We have established links already with a local Python distributor, Enthought, and had an initial meeting with them to discuss our plans. We will evaluate their distribution Canopy, alongside that from Anaconda, python.org, trinket.io, and others. Both PIs are expert in computational physics, and in Python (Richer has professional experience as a software engineer).</p>
</blockquote>
<p><em>Looking back, it’s odd that <a href="http://jupyter.org">Jupyter notebooks</a> and the surrounding technologies don’t even get a mention, given the dominant role they’ve come to have in the project.</em></p>austenlamacraftIn order to give a bit of background on the origins of the PyCav project, I’m attaching the application that John and I made back in January to the Teaching and Learning Innovation Fund.Stack Overflow survey results2016-08-04T14:03:00+00:002016-08-04T14:03:00+00:00https://pycav.github.io/stack-overflow-survey-results<p>The 2016 <a href="https://stackoverflow.com/research/developer-survey-2016">Stack Overflow Developer Survey</a> shows that Python is the <a href="https://stackoverflow.com/research/developer-survey-2016#most-popular-technologies-per-occupation">leading technology</a> for Math & Data developers, far ahead of Matlab.</p>austenlamacraftThe 2016 Stack Overflow Developer Survey shows that Python is the leading technology for Math & Data developers, far ahead of Matlab.Introducing demo server nile.pycav.org2016-08-04T13:47:00+00:002016-08-04T13:47:00+00:00https://pycav.github.io/introducing-demo-server-nile.pycav.org<p>Our demo server <a href="https://nile.pycav.org">Nile</a> is now up and running and ready for you to try. Authenticate via Raven and have a play with any of the demos that the team have been working on.</p>
<p>Inside the demos directory you will find a IPython notebook <code class="highlighter-rouge">index.ipynb</code>, which gives links to the demo notebooks and a short description of each.</p>
<p>We want your comments, and suggestions for more demos!</p>austenlamacraftOur demo server Nile is now up and running and ready for you to try. Authenticate via Raven and have a play with any of the demos that the team have been working on.Python Distributions2016-07-21T16:22:00+00:002016-07-21T16:22:00+00:00https://pycav.github.io/python-distributions<p>We recommend the <a href="https://www.continuum.io/downloads">Anaconda</a> distribution, which installs Python, as well as the Jupyter Notebook used for the demos, and a host of other scientific packages.</p>austenlamacraftWe recommend the Anaconda distribution, which installs Python, as well as the Jupyter Notebook used for the demos, and a host of other scientific packages.