2
$\begingroup$

I am a graduate student in physics and many times when I am working on something/playing around with some expressions I would like to visualize how it looks on the computer. I usually already know (or can figure out) how to numerically get the results.

If what I am looking at is "static" (e.g. Magnetization vs Temperature for the Ising Model) I can visualize it easily using the plotting feature of different libraries (seaborn, mathematica, etc.)

However I have tried searching but I am at a loss how I would even animate something simple like this:

1D Phonons

or something more complicated like this:

Fluid Dynamics

Whenever I try to look it up, it always gives me simulators. I already know how to get the results I just want.

But what software could I use for either feeding in the results or "linking" with the calculation to get a visualization of it?

If there are multiple such programs, what are their strengths and weaknesses?

$\endgroup$
6
  • 1
    $\begingroup$ Tell us something about the programming language you normally use. Simple animations can be produced with most common scientific programming languages, such as Python (I used Matplotlib for some simple stuff), MATLAB, Mathematica, ... $\endgroup$ Mar 24, 2021 at 14:07
  • $\begingroup$ If you just want to animate a graph, get comfortable with “iteration” on an Excel spreadsheet. $\endgroup$
    – R.W. Bird
    Mar 24, 2021 at 14:14
  • $\begingroup$ More on software. $\endgroup$
    – Qmechanic
    Mar 24, 2021 at 14:17
  • $\begingroup$ @DavideDalBosco I use python the most, but occasionally also use C/C++. $\endgroup$
    – JDThinking
    Mar 24, 2021 at 15:13
  • $\begingroup$ You can load your data or write a function in Mathematica and animate them pretty simply using Animate and ListAnimate (and then dealing with Export options). I also hear Python combined with Blender can be useful for illustrative animations (I cannot say anything about loading simulation results into it, though). $\endgroup$
    – Void
    Mar 24, 2021 at 17:52

2 Answers 2

2
$\begingroup$

Whenever I try to look it up, it always gives me simulators.

I don't understand what that means short of something that is a single-problem solution which someone else has written. I guess you want to write your own simulation for a variety of problems.

Depending on the size of the population, Glowscript is a web-based python-like 3D animation language that lets you create 3D particles and shapes and move them around easily. There are tons of examples available at the site or by searching. check it out at http://glowscript.org

Glowscript has also been implemented at http://trinket.io

There is also a package, vpython, that provides 3D animation like glowscript for python.

Python notebooks (Jupyter) allow you to animation parameters of functions one has graphed, and there are several posts at Stack Overflow about this.

$\endgroup$
2
  • $\begingroup$ I think you do understand what I meant but to be clear: when I search "animation software physics simulation" it mostly returns pages that are for teaching (e.g. prewritten software that visualizes electric field based on position of charges). What I want is more like the following: I have the (numerical) solution to the heat equation at each time (e.g. by finite method) and want to make an animation that shows the diffusion of heat over time. $\endgroup$
    – JDThinking
    Mar 24, 2021 at 19:59
  • $\begingroup$ Glowscript is definitely something to investigate. $\endgroup$
    – Bill N
    Mar 25, 2021 at 11:52
0
$\begingroup$

About animation:

Here is what I do to create animation:
(These are animations that run in a browser)

To create a view I use a Javascript library called JSXGraph.

JSXGraph is developed by a small team of people at the 'Lehrstuhl für Mathematik und ihre Didaktik'. Bayreuth, Germany.

JSXGraph generates the SVG code for the view, and it automates creation of all kinds of curves, for instance splines. See the JSXGraph API reference

JSXGraph is designed to be dynamic. The position of any view element can be set up as a function of something else. Because of that dynamic nature JSXGraph readily supports animation.

Animation calculation is programmed in Javascript. The Javascript call 'setInterval' sets up the cycle of rendering the animation frames.


I use JSXGraph because for the viewers that is the most accessible. (The animations are on my website.)

It may be that what you want to create is for personal use only. Apart from accessibility: I think html/javascript is extremely likely to remain backwards compatible forever.

Let's say you start using glowscript. Well, what if that project is abandoned? It could be that at some point in the future you can no longer run those simulations, because there is a breaking change in the rendering platform. I looked at the descriptions of glowscript, and I decided against using it because the architecture kind of looks like a Rube Goldberg machine to me.

JSXGraph: I expect that even if JSXGraph development halts then for the from-that-moment-on-frozen-in-time library no browser incompatibility will arise ever, hence existing animations remaining functional.


Before starting to use JSXGraph I used a simulation environment called EJS.
EJS is the life's work of a spanish mathematician called Francisco Esquembre. EJS runs on the Java Platform.

But when Oracle acquired Sun Microsystems stewardship of the Java platform went to Oracle, and Oracle pushes for business use only. So Francisco Esquembre saw his life's work evaporate, in the sense that today few consumers have Java on their system.

The current state of EJS is that while development of simulations still requires the Java platform, the output is a simulation that runs in the browser. (That is: what is being generated is javascript code.)


The way I understand your question is that your main requirement is that you need a general purpose platform. That means you need a platform that allows you to write the source code for the physics yourself, with the platform providing rendering functionality.
In my case those requirements led me to choosing JSXGraph.

I anticipate that in the future, when I want to do 3D rendering, I will start using a javascript 3D rendering library.

$\endgroup$
2
  • $\begingroup$ Glowscript runs in the browser as Javascript. The python front end is translated to JS. $\endgroup$
    – Bill N
    Mar 25, 2021 at 11:56
  • $\begingroup$ @BillN My concern: as I read the glowscript documentation: there are several different components, I assume the overall process is dependent on those components remaining compatible. The Rapydscript engine for transpiling from Python to Javascript is, by the looks of it, a one man project. What if that project is abandoned? More generally: straddling two frameworks (Python and Javascript) like that is, it seems to me, a risky strategy. I think it's necessary to choose one or the other. $\endgroup$
    – Cleonis
    Mar 25, 2021 at 22:39

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.