Purpose of this blog
I will post random bits and bobs here so I can look them up later when I need them again. This will be mainly pieces of code I repeatedly look for, such as how to set the axis in python to scientific notation.
I will post random bits and bobs here so I can look them up later when I need them again. This will be mainly pieces of code I repeatedly look for, such as how to set the axis in python to scientific notation.
Someone asked an interesting question on Facebook. Given the readings from a particulate matter sensor (PM10 and PM2.5), is there a way to “sanity check” the measurements? The question arose because the sensor sometimes provided negative values for the PM2.5 measurements. Was this miscalibration, a bad sensor or an error in the transmission system that left…
Oomph-lib is an open-source C++ finite-element library, a great versatile tool for 2 and 3-dimensional fluid and solid mechanical modelling. However, it is currently developed on Linux systems. While it is possible to run it on OSX, the setup isn’t trivial. Docker is a container solution, where programs are run in containers, which are isolated…
I recently found myself in the situation where I wanted to get the trajectories of streamlines starting from a specific point. Lots of visualization software offer the possibility to plot streamlines. Two of these are Paraview and Tecplot. Paraview is open-source and generally good, although on dense meshes, streamlines tend to stop randomly. Tecplot is…
When working with fluids, knowing what the flow field looks like is often helpful. While most experimental work is fully three dimensional, a 2D approximation will often capture the essence of the flow. In this post, I will detail how one can use the finite element library oomph-lib to “quickly” calculate the flow in almost any geometry. This will…
The EPSRC, the government funding body that funds mathematical research, requires doctoral candidates to take 100 hours of thought courses at the beginning of their PhD. The University of Manchester has imposed that requirement on all doctoral candidates where the funding source does not explicitly forbid this. Hence I found myself taking the course “Soft…
What is the accuracy of centroid extracted from an image? I recently had a argument with a colleague of mine. Here a simple test. First generate images with a sphere $n$ pixels in diameter, moving across an image. Then measure the centroid using OpenCV in Python. To keep things simple, I will move the spheres in…
I mainly record my experiments using images. As time progresses I often want a new or better measurements, leading me to re-analysing the data. Hence, I often wonder what is the best way to store the data, as analysing thousands of images takes some time. The requirements I found are Speed: It shouldn’t take me…
Using finite differences to solve an equations is quick and easy, especially for ODEs. On the boundaries it is not possible to use the same scheme as in the bulk and hence the boundaries need to be treated separately. I have read several times that, at the boundary, one can use a lower order finite difference approximation.…
I was trying to iterate a system of differential equations and decided to implement it directly in Python to refresh my memory. This is one way to find the approximation of solutions of ordinary differential equations, give some initial value. Higher-order methods (such as RK4) are generally used due to their superior convergence and stability…
To set the axis of a plot with matplotlib in Python to scientific formation, an easy way is to use ticklabel_format, the documentation is here. It is used like this import matplotlib.pyplot as plt #ploting something here plt.ticklabel_format(axis=’x’, style=’sci’, scilimits=(-2,2)) plt.show() where axis can be ‘x‘, ‘y‘ or ‘both‘ style can be ‘sci‘ for scientific…