Embedding HTML5 video in Github Pages

A while back, I wrote some a pair of longer posts about beautifully rendering scientific data using blender. For that data I generated a number of short video clips showing how the magnetic moments in a material reorient themselves when an external magnetic field is applied. Initially I had a lot of trouble embedding the video in the blog; uploading to YouTube and embedding from there is bad because there’s already native support for embedded videos with HTML5 - why should I have to muck about with YouTube to display a simple video? Also, nobody likes it when another video starts playing without being asked when the first is done, along with a bunch recommendations on what to watch next. ...

Undervolting drastically reduces CPU power draw

I’ve spent a decent amount of time overclocking my computers in the past. I’m definitely no expert, but it’s fun to fiddle with the CPU voltages and frequencies, trying to squeeze every last bit of performance out of the CPU. As the CPU frequency is raised beyond the manufacturers default setting, system performance, power draw, and heat produced will increase; at some point the system becomes unstable and will crash or refuse to boot. At this point, overclockers will often raise the CPU voltage, which tends to make the system more stable, at the cost of additional heat production. If your only concern is maximizing performance, you can fight the increased temperatures with a better CPU cooler. Underclocking, by contrast, is the pursuit of lower clocks to minimize power draw and thermal loading. At lower clock frequencies, it may be possible to reduce the CPU voltage, i.e. undervolt, way below the default setting without compromising the system stability, allowing for exceptionally low temperatures and power consumption. ...

Building An Advanced Science-To-Blender Pipeline

I’ve been playing around with blender again. Blender again I’d been thinking about submitting something for this year’s John D. Hunter Excellence in Plotting Contest, but as it turned out I went away for about a week leading up to the final submission date, and didn’t have anything prepared by the last day. I struggled for a few hours before the deadline to come up with something worth submitting, but nothing I tried seemed as visually impressive as I originally hoped it would be. Ultimately I just didn’t have enough time to submit an entry, because I had made plans to travel with my parents on the final submission day, and I wasn’t about to put off going on an awesome trip (Helsinki!) to make figures. But after returning from my trip, I wanted to complete my original goal: use Blender to make a visualization of something related to magnetism. ...

Enhanced rxvt-unicode

I really like rxvt-unicode as a terminal emulator. I can customize nearly everything I want without too much effort, and it seems to do everything I could want a terminal to do. Over time, the changes I’ve made to my configuration files have piled up, and now it’s pretty far from a vanilla setup. Here are a few of my favorite changes. Enable unicode input with Ctrl+Shift+u For anyone who doesn’t use unicode symbols very often, a lot of Linux software accepts unicode input input sequences. Usually, you press Ctrl+Shift+u, followed by the unicode sequence, then Enter. It hasn’t been until relatively recently that I’ve found use for unicode, but I’ve found that a lot of things, and especially math, can be more clearly and concisely expressed with symbols than with whole words. Consider this Python example, which converts spherical coordinates to cartesian, making use of θ and ϕ: ...

Science With Paraview and Blender

I simulate magnetic materials for science. The output of the simulation package that I use is a binary data format (ovf) which I then convert into VTK format. These VTK files contain snapshots of my magnetic material at different points in time, and they can be easily viewed and manipulated using Paraview, a free and open source scientific data analysis and visualization tool developed and maintained by Kitware. If you’re familiar with Kitware (cmake, vtk, …), you probably already know that the documentation for these tools is …incomplete? A work in progress? Look, if you work at Kitware, I’m really sorry, this isn’t some sort of attack on you - I know how difficult good documentation can be. But there’s a really steep learning curve, so I’m hoping that showcasing how I use Paraview will help others get over this barrier. Here’s what the data looks like when I load it in: ...

Solving Linear ODEs With Multigrid

Introduction About a year ago, I was working on a for-fun problem where I needed to determine the voltage from an arbitrary charge distribution along 1 dimension. This is the problem of solving a linear differential equation (in this case Poisson’s equation) given a driving function $f$: $$ \begin{aligned} -\nabla^2 v = f \tag{\htmlId{poisson}{1}} \end{aligned} $$Unless we’re involved in developing numerical libraries, it’s not too often that we think about how these problems can be solved numerically. The fact there aren’t very many blog posts about this kind of stuff shows how infrequently we think about these sorts of algorithms, so I wanted to give it a shot. ...

LAMMPS Installation in Manjaro

I’ve been interested in doing some molecular dynamics (MD) simulations for a project I’ve been thinking about for a long time, but it’s only recently that I’ve had the time to start tinkering with MD simulation packages. There are a few large projects to choose from if you’re looking to get into MD simulations, with GROMACS and LAMMPS being two of the more widely used packages. Although the literature suggests that GROMACS can be used for MD simulations of crystalline systems, it just seemed to me like it has been primarily used for simulating biological systems - proteins and that kind of stuff. So I decided to check out LAMMPS, an MD simulator maintained by Sandia, with contributions from people all over the world. ...

Brightness Control with X11

I’m one of those people who likes having everything on my devices set to night mode. It’s becoming more common to see dark themes everywhere, but I still rely on tools like the Stylus plugin for firefox/chrome (with dark themes installed for all of my favorite websites), which absolutely saves my eyeballs. And at night I like to dim my desktop monitors so that I don’t get blinded by any white light I can’t really avoid. It turns out that doing this can be kind of tricky with X11. When I tried to find information about how to do this the discussion was most often focused on laptop brightness control - but there was hardly ever mention of controlling brightness on desktop monitors. It took me a little while but I figured out a good way to do this using xrandr and some scripting. I’ve written a line-by-line walkthrough of the bash script I wrote in case you’re interested, but if not just scroll to the bottom if you want my script file. ...

Parallelization in Python

Recently, incredible changes to computationally intensive fields have been brought about by insanely powerful systems designed for parallel processing. Deep learning is all the rage. Parallelization is way simpler to implement than it used to be. And yet I think many of us in science who program at least semi-regularly tend to avoid writing parallel code because it’s easy to feel like you’ll go down the rabbit hole searching through documentation on how to do it properly. We even avoid writing efficient code because we can get away with it. These days computers are so fast that the overhead associated with doing something in an inefficient way oftentimes doesn’t matter much. That being said, Python’s multiprocessing library has made it so easy to implement parallelization that we no longer have any excuse not to use it all the time. ...

Fixing Matplotlib's Scientific Notation

I use matplotlib all the time, but one of the most common problems I run into is when my axes are plotted on a scale that uses scientific notation. This is especially annoying when you’re trying to make two plots stacked on top of each other which share an x-axis. Here’s a simple example of the issue: import matplotlib matplotlib.use("Qt5Agg") import matplotlib.pyplot as plt import numpy as np x = np.linspace(0, 10, 1000) y = np.sin(x) z = 1e12\*(1-np.exp(-x)) fig = plt.figure() fig.subplots_adjust(hspace=0.05) upperAxes = fig.add_subplot(211) upperAxes.plot(x, y, color='k', linestyle='-') upperAxes.set_xticklabels([]) upperAxes.set_ylabel("y") lowerAxes = fig.add_subplot(212) lowerAxes.plot(x,z, color='r', linestyle='-') upperAxes.set_xlabel("x") upperAxes.set_ylabel("y") plt.savefig("example.svg") This code produces the following: ...