Starfish Tutorial Part 2: Particles and Animation

Posted on November 6th, 2012
Previous Article :: Next Article


Welcome to the second part of the Starfish plasma simulation code tutorial. In this part we will continue with the example started in Part 1. Our goal is to model the flow of plasma over an infinitely long cylinder (since Starfish is a two-dimensional code). In the last example, we set up the computational domain, specified the cylinder geometry, and used the Poisson solver to compute the initial potential. In this example we will add particles. We will also touch upon few visualization options useful for generating animations.

Adding Particles

In order to add particles, we need to specify sources. Starfish supports two types of sources: volume and surface. Here we will use the latter. Surface sources create particles along geometry splines according to a prescribed velocity distribution function (VDF) and the surface normal vector. In this example, we want the entire left domain boundary to act as a source injecting particles with uniform velocity. This setup then approximates the movement of the cylinder through undisturbed plasma, with the frame of reference moving with the cylinder. First, we need to add a new boundary to the boundaries.xml file:

<boundary name="cylinder" type="solid" value="-1">
<path>M 0.0500000,0.00000 L 0.0475528,0.0154508 0.0404508,0.0293893 0.0293893,0.0404508
0.0154508,0.0475528 3.06162e-18,0.0500000 -0.0154508,0.0475528 -0.0293893,0.0404508 -0.0404508,0.0293893
-0.0475528,0.0154508 -0.0500000,6.12323e-18 -0.0475528,-0.0154508 -0.0404508,-0.0293893
-0.0293893,-0.0404508 -0.0154508,-0.0475528 -9.18485e-18,-0.0500000 0.0154508,-0.0475528
0.0293893,-0.0404508 0.0404508,-0.0293893 0.0475528,-0.0154508 0.0500000,-1.22465e-17</path>
<boundary name="inlet" type="virtual">
<path>M -0.15,0 L -0.15, 0.2</path>

We named this spline “inlet” and it was given a type of virtual. This classification means that the boundary will not be used in generating the mesh intersections nor will it be seen by the particles. However, it is available for use by sources and also by probes (but more about probes later). This spline is simply a linear segment from the bottom left to the top left corner of the computation mesh. As you can see, it is 0.2m long.

To add the source, we add the following command to starfish.xml (this command could also be placed in an external file and loaded with the load command):

<!-- set sources -->
<boundary_source name="space">

Here you can see how the boundary comes into play. The source is given type uniform, which means that it produces particles with velocity equal to v_drift. The particles will be moving in the direction of the surface normal of the associated boundary, the inlet. If the boundary consisted of a number of individual splines, the particles would be moving according to the local normal.

This source will generate O+ particles at mass flow rate of 5.313e-11 kg/s. You may be wondering how this number was determined. We want our plasma density in the free space to be \(10^{12}\, \text{m}^{-3}\), to correspond with the potential solver electron model settings. The mass flow rate is given by the following expression:
$$\dot{m}=m n u A$$
where the terms on the RHS correspond to the atomic mass (16 amu, per materials.xml file), number density (1e12 m-3), velocity (10,000 m/s), and source area (0.2 m^2). In the Cartesian (XY) mode, the area is equal to the spline length, since unit depth is assumed. This expression gives us the value that is used in the simulation.

Also, since we now have particles, we need to run for enough time steps to reach the steady state. In this case, 400 time steps will do the trick. We modify the time command as follows:

<!-- set time parameters -->

And that’s it. You will find the complete set of input files here: After we run the simulation, we obtain the following results (plotted with Tecplot). We can see that a wake forms behind the cylinder. We can also clearly see the “reflection” of ions at the centerline, the line of symmetry. In reality, this reflection corresponds to the influx of particles from the opposite half of the simulation. This is best seen in the plot of the vertical velocity.

ion density for a flow over a cylinder
vertical velocity for plasma flow over a cylinder
potential for plasma flow over a cylinder
Figure 1. Ion density, ion vertical velocity, and plasma potential for flow over a cylinder


The above results show the final solution at the end of the simulation. These results correspond to the instantaneous steady state results. But what if we wanted to learn more about how the solution progressed? Or what if we had a time-dependent injection source? This is where animations come in. Animations direct the simulation to save results at a prescribed frequency during the course of the computation. Animations are specified by wrapping the standard output command in an animation command:

<!-- save animation -->
<animation start_it="1" frequency="10">
<output type="2D" file_name="field_ani.dat" format="tecplot" variables="phi,nd.O+,u.O+,v.O+" />

Here we specify just one animation set consisting of one output command that starts outputting with time step 1, and saves data every 10 time steps. The simulation can contain multiple animations (each with different start time step and frequency) with each containing multiple output commands. This command then allows us to make animated GIF movies.

animation of vertical velocity for a plasma flow around a cylinder
animation of plasma potential evolution for a plasma flow around a cylinder
Figure 2. Animations for the plasma flow over a cylinder:

More Fun with Starfish: Constant Electric Field

Finally, a bit more fun with Starfish. The Poisson solver is just one of many solvers available in the simulation. One of the other “solvers” is a constant electric field model. Instead of solving for plasma potential self consistently, this model simply specifies uniform electric field components everywhere in the domain. We can use this model to create an electric field directing ions toward the centerline.

<solver type="constant-ef">

Since the ions already have an initial horizontal velocity, this results in an interesting waterfall-like response, especially around the cylinder. We can also clearly see that density decreases as velocity increases, as expected.

animation of flow over a cylinder in constant electric field
Figure 3. Evolution of ion density for a plasma flow in a constant electric field

Continue to Starfish Tutorial Part 3.

Subscribe to the newsletter and follow us on Twitter. Send us an email if you have any questions.

Leave a Reply

You can use these tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong> <pre lang="" line="" escaped="" cssfile=""> In addition, you can use \( ...\) to include equations.