Mathcad Exercises

 We are moving: This site will move to cips.Colorado.edu around September 1, 2012.

Send corrections to scott.robertson [at] colorado.edu.

For a summary of the conversion to Prime 2.0 and related issues, scroll down to the area below all of the exercises.

Table of Contents

Preliminaries:  Mathcad Primer

Introduction to Mathcad, written by Prof. Dubson

Short introduction to Mathcad.  This document is NOT a "live" Mathcad document, but rather a printable PDF.  It is still handy, though.

The intro was not written for use with Mathcad Prime. 

Ch.0  Mathcad Essentials

Variables types and simple operations

Examples are given of simple mathematical operations and a simple graph.

0_Essentials_Variables.xmcd

0_Essentials_Variables.mcd

0_Essentials_Variables.pdf

 

Matrices

This exercise demonstrates how to enter matrices and the matrix operations from the matrix toolbar.

Also illustrated are the rows, cols, stack, augment, reverse and submatrix functions.

0_Essentials_Matrices.xmcd

0_Essentials_Matrices.mcd

0_Essentials_Matrices.pdf

 

Vectors, lookups, and interpolation

This exercise demonstrates the standard vector operations and operations that might be used on data stored as vectors, such as reverse, value lookup, index lookup (match), max, min, linear interpolation, spline interpolation, and extrapolation. 

0_Essentials_Vectors.xmcd

0_Essentials_Vectors.mcd

0_Essentials_Vectors.pdf

 

Boolean functions and If(,,)

This exercise demonstrates the if(,,) function and some of the Boolean functions such as >, <, or, and, not, and xor. Typing hints are given for if(,,).

0_Essentials_Boolean.xmcd

0_Essentials_Boolean.mcd

0_Essentials_Boolean.pdf

 

Plots of vectors, matrices and bitmaps

Examples are given of contour and mesh plots for data that are a function of two variables. Also illustrated is Picture from the matrix toolbar.

0_Essentials_Plots.xmcd

0_Essentials_Plots.mcd

0_Essentials_Plots.pdf

 

Creating and editing programs and loops

This exercise illustrates how to type in programs containing loops. The confusing task of opening new lines within, above, or below loops is illustrated.

0_Essentials_Program_Loops.xmcd

0_Essentials_Program_Loops.mcd

0_Essentials_Program_Loops.pdf

 

Units

This short exercise demonstrates using units and making units conversions.

0_Essentials_Units.xmcd

0_Essentials_Units.mcd

0_Essentials_Units.pdf

Ch.1  Electrostatics

Plotting the field of an electrostatic dipole

 

This exercise begins by using the vector field plot to display the field of a single charge and of a pair of charges.

For the dipole, the lines of force are followed by integrating a short differential distance ds that is parallel to the E field.

Euler's method is used for the integration. Field line plots are also made in the Magnetostatics Exercises below.

1_ES_Dipole_plot.xmcd

1_ES_Dipole_plot.mcd

1_ES_Dipole_plot.pdf

1_ES_Dipole_plot_prime2.0.mcdx

 

Laplace Solver

 

This exercise shows how successive approximations are used to obtain solutions to Laplace’s equation on a 2-d grid.

Physics/math content: teaches that a characteristic of Laplace’s equation is that the potential at a grid point is the average of the values at the neighboring grid points.

Mathcad content: program loop, if function, relax function, matrices, matrix transpose.

Mathcad graphics: Contour plots

1_ES_Laplace.xmcd

1_ES_Laplace.mcd

1_ES_Laplace.pdf

1_ES_Laplace_prime2.0.mcdx

 

Laplace's Equation with a Dielectric

 

This exercise solves Laplace's equation first in one dimension for a dielectric slab between biased plates.

Then Laplace's equation is solved on a two dimensional grid for a dielectric rod between biased plates.

The content is similar to that for the Laplace Solver exercise.

1_ES_Laplace_Dielectric.xmcd

1_ES_Laplace_Dielectric.mcd

1_ES_Laplace_Dielectric.pdf

1_ES_Laplace_Dielectric_prime2.0.mcdx

 

Poisson’s Equation and Debye Shielding

This exercise shows how successive approximations are used to obtain solutions to Poisson’s equation in one-dimension.

It uses electron and ion densities determined by the Boltzmann factor.

Physics content: shows that the potential around an electrode placed in plasma decays exponentially with distance. Demonstrates the utility of dimensionless units.

Math content: shows a numerical instability and how to stop it.

Mathcad content: Program loop.

Mathcad graphics: Simple x,y plots.

1_ES_Poisson.xmcd

1_ES_Poisson.mcd

1_ES_Poisson.pdf

1_ES_Poisson_prime2.0.mcdx

 

Poisson's equation in cylindrical geometry

 

The finite-difference form of Poisson’s equation in cylindrical geometry is solved by the relaxation method, first assuming no z dependence and then allowing a z dependence.

A cylinder of charge is assumed to be within a cylindrical container at zero potential. This extends the previous exercise to cylindrical coordinates.

1_ES_Poisson_Cylindrical.xmcd

1_ES_Poisson_Cylindrical.mcd

1_ES_Poisson_Cylindrical.pdf

1_ES_Poisson_Cylindrical_prime2.0.mcdx

 

The ionosphere: Separation of ions by gravity

 

The ionosphere contains ions of both oxygen, O+, and hydrogen, H+. The proportion of H+ increases with altitude because the H+ is lighter.

The electrons are the lightest species, but are constrained by quasineutrality to be at the same altitude as the ions.

In this exercise we use the relaxation methods for Poisson's equation to apply the quasineutrality constraint and find the altitude dependence of the densities of O+, H+, and electrons.

1_ES_Separation_Of_Ions.xmcd

1_ES_Separation_Of_Ions.mcd

1_ES_Separation_Of_Ions.pdf

1_ES_Separation_Of_Ions_prime2.0.mcdx

Ch.2  Magnetostatics

Magnetic Field of Parallel Wires

This exercise plots the field of a single wire, two wires with parallel currents, and two wires with antiparallel currents.

A magnetic “x point” is illustrated. The vector fields are added.

Physics content: The azimuthal field of a wire is projected onto the x and y directions.

Mathcad graphics: Plots a vector field in two dimensions.

2_Bfield_Wires.xmcd

2_Bfield_Wires.mcd

2_Bfield_Wires.pdf

2_Bfield_Wires_prime2.0.mcdx

 

Plotting Field Lines

 

This exercise shows how to integrate with Runge Kutta a unit vector to obtain a curve in 3-d space. The components of Bq are projected onto the x and y directions.

Mathcad content: Demonstrates the Runge-Kutta solution of a differential equation using rkfixed.

Mathcad graphics: illustrates a 3-d scatter plot that can be tilted by the user.

2_Bfield_plotting.xmcd

2_Bfield_plotting.mcd

2_Bfield_plotting.pdf

2_Bfield_plotting_prime2.0.mcdx

 

Field of a Loop

 

This exercise plots the field of a loop of wire. The expression for B involves the complete elliptic integrals E(k) and K(k). These integrals are defined at the outset.

The unit vector is found in the r,z plane and integrated. The result is B looping around the minor axis for points close to this axis.

In a second plot, a constant field is added which makes an x point.

Mathcad content: integration of a unit vector as in the field line plotting exercise. Evaluation of elliptic integrals. TOL is used to decrease calculation time.

Mathcad graphics: 2-d plots of lines.

2_Bfield_of_a_loop.xmcd

2_Bfield_of_a_loop.mcd

2_Bfield_of_a_loop.pdf

2_Bfield_of_a_loop_prime2.0.mcdx

 

B Field of the tokamak

 

This exercise plots the magnetic surface mapped by a magnetic field line of a tokamak.

It follows a magnetic field line created by a current loop perpendicular to the z axis and a wire along the z axis.

The concepts of magnetic surface and aspect ratio are discussed. The content is similar to that in Field of a Loop.

2_Bfield_tokamak.xmcd

2_Bfield_tokamak.mcd

2_Bfield_tokamak.pdf

2_Bfield_tokamak_prime2.0.mcdx

Ch.3  Lorentz Equations of Motion

Gyrating motion: a video

This exercise integrates the Lorentz equations of motion (v x B only) in 2-d with no E field.

There are two coupled equations for vx and vy which are put into a video. A simple plot shows that the two velocities are out of phase.

The effect of time step on error is discussed briefly.

Mathcad content: illustrates Runge Kutta (rkfixed).

Mathcad graphics: demonstrates making a video using the Animate command.

Download video: Gyration4.avi.

3_Lorentz_GyroMotion.xmcd

3_Lorentz_GyroMotion.mcd

3_Lorentz_GyroMotion.pdf

Not supported in Prime 2.0

 

Deflection of a particle beam by a bending magnet

 

This exercise follows a charged particle beam through a bending magnet. The beam is also focused.

The Runge-Kutta integrator is used to integrate the equations of motion in two dimensions.

Mathcad content: rkfixed.

3_Lorentz_Bending_Magnet.xmcd

3_Lorentz_Bending_Magnet.mcd

3_Lorentz_Bending_Magnet.pdf

3_Lorentz_Bending_Magnet_prime2.0.mcdx

 

E x B drift in uniform fields

 

This exercise integrates the Lorentz equations of motion in 3-d, though two would do for the E x B drift.

There are six equations to be integrated and six phase space variables. The E x B drift is plotted and simple acceleration along B.

Mathcad content: rkfixed. ORIGIN = 1 is used to make subscripts 1,2,3 correspond to x,y,z.

3_Lorentz_ExB.xmcd

3_Lorentz_ExB.mcd

3_Lorentz_ExB.pdf

3_Lorentz_ExB_prime2.0.mcdx

 

Drifts in the field of a wire

 

This demonstrates the gradient drift and the curvature drift in the azimuthal field around a straight wire.

The initial conditions are adjusted so the two drifts appear together and appear separately.

This is more sophisticated than the previous exercise because B is now a function of position and must be calculated.

Mathcad content: rkfixed, vector cross product, ORIGIN.

Mathcad graphics: a 3-d scatter plot with gradient shading and with two arguments. ORIGIN.

3_Lorentz_Drifts.xmcd

3_Lorentz_Drifts.mcd

3_Lorentz_Drifts.pdf

3_Lorentz_Drifts_prime.2.0.mcdx

 

Ion motion in the Earth’s magnetic field: Van Allen’s belts

The earth’s field is represented as a dipole and a dipole expansion is used for Bx, By and Bz. There are three vector components of B, which vary spatially.

First, a plot of some field lines from pole to pole. Then an ion is followed. Real units are used so distances are in meters and time in seconds.

Physics content: Demonstrates magnetic mirroring.  

Mathcad content: rkfixed, vector cross product, ORIGIN, stack for matrices.

3_Lorentz_VanAllen.xmcd

3_Lorentz_VanAllen.mcd

3_Lorentz_VanAllen.pdf

3_Lorentz_VanAllen_prime2.0.mcdx

 

Particle Orbits in the Multidipole Device

 

This exercise finds the trajectory of a 1 eV electron in a common type of laboratory plasma device in which a cold plasma is confined by a multidipolar field.

The magnetic field components are a function of only x and y, thus the field values are calculated in advance and placed in a matrix.

During the trajectory calculation, the field values at the electron location are found by a two-d interpolation.

A wire array is used to generate a magnetic field similar to that of the permanent magnets. The magnetic vector potential is calculated and plotted.

3_Lorentz_Multi_Dipole.xmcd

3_Lorentz_Multi_Dipole.mcd

3_Lorentz_Multi_Dipole.pdf

3_Lorentz_Multi_Dipole_prime2.0.mcdx

 

Banana orbits in tokamaks

This exercise uses the drift approximation to find the path followed by an energetic ion in a tokamak.

The equation of motion parallel to B for the bounce motion caused by the mirror force is solved simultaneously with the equation for the vertical drift.

3_Lorentz_Bananas.xmcd

3_Lorentz_Bananas.mcd

3_Lorentz_Bananas.pdf

3_Lorentz_Bananas_prime2.0.mcdx

Ch.4  Fluid-Poisson System of Equations

Child’s law

The flow of electrons from a cathode to an anode is followed with the potential found from the fluid continuity equation and Poisson’s equation.

The analytic solution is compared with the Runge Kutta solution.

Mathcad content: rkfixed. A method is given for solving a differential equation for a range of values of a coefficient in the equation.

The “trick” is to put the coefficient in the list of boundary conditions.

4_FP_Child.xmcd

4_FP_Child.mcd

4_FP_Child.pdf

4_FP_Child_prime2.0.mcdx

 

Bohm’s sheath

The fluid continuity equation and Poisson’s equation are solved for the sheath that occurs at the boundary of a plasma.

This is similar to Child’s law but has both electrons and ions.

Mathcad content: rkfixed. “Shooting” is demonstrated; root is used to find a starting condition by trial and error. 

4_FP_Bohm.xmcd

4_FP_Bohm.mcd

4_FP_Bohm.pdf

4_FP_Bohm_prime2.0.mcdx

 

Sheath and presheath

The potential profile from the midplane to the wall is found using Poisson’s equation.

The electron density is modeled by the Boltzmann relation and the ion density is found by solving the continuity and momentum equations for the ions.

A homogeneous source of ionization is assumed.

4_FP_Sheath_Presheath.xmcd

4_FP_Sheath_Presheath.mcd

4_FP_Sheath_Presheath.pdf

4_FP_Sheath_Presheath_prime2.0.mcdx

Ch.5  Waves

Electrostatic waves in a cold magnetized plasma

The dispersion relation for a magnetized cold plasma with electrons and ions is solved.

For a given k and angle of propagation, a root finder is used to find the frequencies of waves.

The upper and lower hybrid frequencies are found for perpendicular propagation and the plasma frequency is found for parallel propagation.

Physics content: frequencies of waves in magnetized plasma

Mathcad content: root finding on an interval or with an initial guess, using root.

5_Waves_ES.xmcd

5_Waves_ES.mcd

5_Waves_ES.pdf

5_Waves_ES_prime2.0.mcdx

 

Extraordinary wave dispersion relation

Similar to the above exercise except this wave is electromagnetic. The vectors E and k are perpendicular to B.

There are two roots to the dispersion relation that are found using the polyroots function.

Mathcad content: polyroots

5_Waves_EM.xmcd

5_Waves_EM.mcd

5_Waves_EM.pdf

5_Waves_EM_prime2.0.mcdx

 

Ray tracing in an inhomogeneous medium

The ray of a radio wave is followed as it approaches the ionosphere. The ray bends gradually and descends back to the earth’s surface.

The differential equations that advance the position x and the wavevector k are presented and solved by Runge Kutta in three dimensions.

The equations are based on the WKB approximation. The dispersion relation w(k,x) is a function of altitude because of the increasing electron density.  5_Waves_Ray_tracing.xmcd

5_Waves_Ray_tracing.mcd

5_Waves_Ray_tracing.pdf

5_Waves_Ray_tracing_prime2.0.mcdx

Ch.6  Waves with Complex w

Two stream instability

This looks at the fluid dispersion relation for a beam of cold electrons flowing through a background of ions.

Mathcad content: uses the root finder root to search for complex roots of an expression given a guess. Uses polyroots for find the roots of a polynomial expression.

Graphics content: simple x, y plots.

6_Waves_Complex_Two_Stream.xmcd

6_Waves_Complex_Two_Stream.mcd

6_Waves_Complex_Two_Stream.pdf

6_Waves_Complex_Two_Stream_prime2.0.mcdx

 

Landau dispersion relation and Landau damping

This exercise evaluates the dispersion relation for electrostatic plasma waves using the Vlasov equation.

The real part of the dispersion relation is expressed in terms of the W function.

Both the principal value integral is found and the value from expansion of the denominator as a power series.

The imaginary part is plotted showing that waves with k < 0.2 are weakly damped.

Math content: principal value integral.

Mathcad content: Evaluation of integrals with integrable singularities.

6_Waves_Complex_Landau_Damping.xmcd

6_Waves_Complex_Landau_Damping.mcd

6_Waves_Complex_Landau_Damping.pdf

6_Waves_Complex_Landau_Damping_prime2.0.mcdx

Ch.7  Random Walks, Collisions, Resistivity and Diffusion 

Random numbers and random events

Uses the rnd(1) function to generate random numbers on the interval 0,1.

A logarithmic “stretch” is used to generate the time intervals between random events. The decay of a population of 1000 nuclei is simulated.

Lastly, speeds are selected from a Maxwellian distribution by the rejection method that is applicable to any distribution function.

Mathcad content: rnd, hist, if, program loop.

Mathcad graphics: Bar charts, stem charts and histogram function.

7_Random_Random_numbers.xmcd

7_Random_Random_numbers.mcd

7_Random_Random_numbers.pdf

7_Random_Random_numbers_prime2.0.mcdx

 

Random walks and diffusion

The trajectories of particles are followed with randomly occurring collisions that change the direction of the velocity vector but not the length.

This corresponds to elastic electron-neutral collisions. A collection of particles is started at the origin and the spreading of the locations with time is followed.

This is done both in two and three dimensions, with random walks characterized either by a mean time between collisions or a mean free path between collisions.

The mean square distance is compared with that from the diffusion equation.

Physics content: collisions with constant mean free path or with constant mean free time.

Mathcad content: same as in Random numbers and random events.

7_Random_Random_Walks.xmcd

7_Random_Random_Walks.mcd

7_Random_Random_Walks.pdf

7_Random_Random_Walks_prime2.0.mcdx

 

Resistivity

An electric field is added to the random walk above. The particles then attain a drift velocity from which the current and resistivity can be determined.

The mean squared velocity increases with time showing resistive heating. It is shown that the results conserve energy.

Physics content: resistivity, mobility, resistive heating.

7_Random_Resistivity.xmcd

7_Random_Resistivity.mcd

7_Random_Resistivity.pdf

7_Random_Resistivity_prime2.0.mcdx

 

Diffusion equation

The diffusion equation is solved using the simplest finite-difference method in Numerical Recipes.

A top hat initial distribution is evolved in time showing the rapid rounding of the corners (higher order modes) and slower decay of the lowest order mode.

The decay of the lowest order mode is shown to agree with the solution obtained by separation of variables.

Math content: a finite difference method for the diffusion equation.

Mathcad content: Matrix operations. A matrix defined as a function of variables. Program loop.

Mathcad graphics: 3-d surface plot with time on one axis.

7_Random_Diffusion.xmcd

7_Random_Diffusion.mcd

7_Random_Diffusion.pdf

7_Random_Diffusion_prime2.0.mcdx

 

Diffusion in Cylindrical Geometry

 

This simply repeats the Diffusion Equation exercise in cylindrical geometry.

7_Random_Diffusion_cylindrical.xmcd

7_Random_Diffusion_cylindrical.mcd

7_Random_Diffusion_cylindrical.pdf

7_Random_Diffusion_cylindrical_prime2.0.mcdx

Ch.8  Kinetic Theory

Liouville’s equation

The flow of electrons is followed from a thermionic cathode to an anode as in Child’s law. The initial distribution function is a half-Maxwellian and the evolution of this distribution is followed showing that an accelerating beam becomes “colder” as a consequence of the preservation of phase space density.

8_Kinetic_Liouville.xmcd

8_Kinetic_Liouville.mcd

8_Kinetic_Liouville.pdf

8_Kinetic_Liouville_prime2.0.mcdx

 

Fokker-Planck Equation

The Fokker-Planck Equation describes the evolution of a distribution function as a consequence of collisions of the particles among themselves.

This exercise applies the Lax-Wendroff method to solving the Fokker-Planck equation.

In the first example, a distribution function with a cutoff tail is followed in time, showing that the tail is filled-in by collisions.

In the second example, a beam of particles is followed as it is slowed by collisions.

8_Kinetic_Fokker_Planck.xmcd

8_Kinetic_Fokker_Planck.mcd

8_Kinetic_Fokker_Planck.pdf

8_Kinetic_Fokker_Planck_prime2.0.mcdx

 

Landau Damping from a Numerical Solution to the Vlasov Equation

The Cheng-Knorr algorithm is used to solve the Vlasov-Poisson system of equations to find Landau damping of an electrostatic wave.

8_Kinetic_Cheng_Knorr.xmcd

8_Kinetic_Cheng_Knorr.mcd

8_Kinetic_Cheng_Knorr.pdf

8_Kinetic_Cheng_Knorr_prime2.0.mcdx

 

Source and Collector Sheaths

This extends the treatment of the sheath problem to a plasma of two species. The Q machine has a hot plate that emits both electrons and ions.

This exercise finds the potential profile in the device (1) with emitters at both ands and (2) with an emitter at one end and a collector at the other end.

The collector is assumed floating and the potential on the collector is updated continually to be consistent with the plasma properties.

Kinetic theory is used to find the left-going and right-going electron and ions distribution functions at each grid point.

8_Kinetic_Source_Sheath.xmcd

8_Kinetic_Source_Sheath.mcd

8_Kinetic_Source_Sheath.pdf

8_Kinetic_Source_Sheath_prime2.0.mcdx

 

Sheath Above an Electron Emitter

A sheath composed only of electrons, a "virtual cathode", forms above a surface that emits electrons, such as a thermionic or photoelectric emitter.

This exercise uses Poisson's equation to find the potential profile between parallel planes, one of which is emitting a one-sided Maxwellian distribution of electrons. Kinetic theory is used to find the electron distribution at each point between the plates.

8_Kinetic_Photoelectron_sheath.xmcd

8_Kinetic_Photoelectron_sheath.mcd

8_Kinetic_Photoelectron_sheath.pdf

8_Kinetic_Photoelectron_sheath_prime2.0.mcdx

Ch.9  Data Analysis

Langmuir Probe Data Analysis

This exercise analyzes the data from a cylindrical Langmuir probe and finds the electron temperature and electron density.

A second more sophisticated analysis resolves the electron distribution into the sum of two populations with different temperatures.

9_Data_Langmuir_Probe.xmcd

9_Data_Langmuir_Probe.mcd

9_Data_Langmuir_Probe.pdf

9_Data_Langmuir_Probe_prime2.0.mcdx

 

Druyvesteyn's Probe Analysis

In 1930 Druyvesteyn showed that the electron speed distribution is proportional to the second derivative of the probe data.

This lengthy exercise imports probe data, removes the ion contribution to the probe current, and finds the electron speed distribution.

For comparison, it also finds the two Maxwellian distributions that best describe the data.

A new method is used to find the distribution function projected on the the plane perpendicular to the probe axis. This method is less affected by noise.

9_Data_Druyvesteyn_Method.xmcd

9_Data_Druyvesteyn_Method.mcd

9_Data_Druyvesteyn_Method.pdf

9_Data_Druyvesteyn_Method_prime2.0.mcdx

Ch.10  Miscellaneous Exercises

Harmonic oscillator

This exercise introduces Runge-Kutta to solve equations of motion in one dimension. The second order differential equation is expressed as two first order equations.

Mathcad content: illustrates Runge Kutta (rkfixed).

10_Misc_Harmonic_Oscillator.xmcd

10_Misc_Harmonic_Oscillator.mcd

10_Misc_Harmonic_Oscillator.pdf

10_Misc_Harmonic_Oscillator_prime2.0.mcdx

 

Harmonic Oscillator with Energy Conservation

This exercise is a second way of solving  the harmonic oscillator problem that uses conservation of energy.

The velocity is found as a function of position using energy conservation, and the velocity is integrated to find the position as a function of time. Energy conservation determines the square of the velocity, and whether the positive or negative value of the square root is used is determined using the sign of the velocity obtained from a linear extrapolation.

Mathcad content: illustrates Runge Kutta (rkfixed).

10_Misc_Harmonic_Oscillator_2.xmcd

10_Misc_Harmonic_Oscillator_2.mcd

10_Misc_Harmonic_Oscillator_2.pdf

10_Misc_Harmonic_Oscillator_2_prime2.0.mcdx

 

Orbital motion

An electron orbits an ion classically. This could also be celestial mechanics. Turning on a weak perturbation destroys the spherical symmetry and causes the orbit to tilt.

This demonstrates the electric part of the Lorentz force in three dimensions. Introduces using Runge Kutta for three-dimensional motion. A six dimensional phase space is introduced.

Mathcad content: illustrates Runge Kutta (rkfixed), and the stack and sub matrix commands.

Graphics content: 2-d and 3-d point plots.

10_Misc_Orbital_motion.xmcd

10_Misc_Orbital_motion.mcd

10_Misc_Orbital_motion.pdf

10_Misc_Orbital_motion_prime2.0.mcdx

 

Paul trap, ponderomotive force, and Mathieu’s equation

The motion of an ion in a Paul trap is followed in the r,z plane. Containment is from the ponderomotive force exerted by AC potentials on external electrodes.

The problem is in (r,z) coordinates and the equations of motion along r and z are solved by Runge Kutta.

The relation to Mathieu’s equation is discussed and the student is encouraged to examine stability.

Physics content: ponderomotive force.

10_Misc_Paul_Trap.xmcd

10_Misc_Paul_Trap.mcd

10_Misc_Paul_Trap.pdf

10_Misc_Paul_Trap_prime2.0.mcdx

 

Standard Map

This exercise examines the Standard Map of nonlinear dynamics. A program loop is used to find the mappings for a wide variety of seed values.

10_Misc_Standard_Map.xmcd

10_Misc_Standard_Map.mcd

10_Misc_Standard_Map.pdf

10_Misc_Standard_Map_prime2.0.mcdx

 

Fluid flow from a potential function (new in 2008)

The relaxation method is used to find a potential function that describes the incompressible flow of fluid in a nozzle.

A second solution is found with an object placed in the flow.

10_Misc_Fluid_flow_I.xmcd

10_Misc_Fluid_flow_I.mcd

10_Misc_Fluid_flow_I.pdf

10_Misc_Fluid_flow_I_prime.2.0.mcdx

Fluid flow from a stream function (new in 2008)

The relaxation method is used to find a stream function that describes the incompressible flow of fluid in a nozzle.

A second solution is found that is circular flow about an object placed in the flow.

10_Misc_Fluid_flow_II.xmcd

10_Misc_Fluid_flow_II.mcd

10_Misc_Fluid_flow_II.pdf

10_Misc_Fluid_flow_II_prime2.0.mcdx

Equilibria of a Cylindrical Plasma (new in 2008)

 

The MHD equilibrium equation J x B - grad P = 0 is integrated to find the current and magnetic field profiles in cylindrical geometry:

First with pressure and no axial current, second with axial current and no pressure, and third with both axial current and pressure.

10_Misc_Equilibria_cylindrical.xmcd

10_Misc_Equilibria_cylindrical.mcd

10_Misc_Equilibria_cylindrical.pdf

10_Misc_Equilibria_cylindrical_prime2.0.mcdx

Axisymmetric equilibria from the Grad-Shafranov equation (new in 2008)

The Grad-Shafranov equation is derived and used to find equilibria satisfying J x B - grad P = 0 for a tokamak.

A relaxation method is used that is similar to the method used for Poisson's equation.

The program finds the current densities Jr, Jz, and Jf as well as the fields Br and Bz.

The inputs are the rectangular boundaries, the pressure on the magnetic axis, the safety factor q on the magnetic axis, and the applied toroidal field Bf

10_Misc_Grad_Sharanov.xmcd

10_Misc_Grad_Sharanov.mcd

10_Misc_Grad_Sharanov.pdf

10_Misc_Grad_Sharanov_prime2.0.mcdx

Ch.11  Finite Difference Methods

Numerical Integration of a Function

This exercise introduces the concept of a grid of points and finds the area under a curve by Simpson’s rule.

 11_Finite_Num_Int_Function.xmcd

11_Finite_Num_Int_Function.mcd

11_Finite_Num_Int_Function.pdf

11_Finite_Num_Int_Function_prime2.0.mcdx

 

Numerical Integration of Derivatives

This exercise compares integration by Euler’s method, by the midpoint method, and by the fourth order Runge-Kutta method.

 11_Finite_Integration_methods.xmcd

11_Finite_Integration_methods.mcd

11_Finite_Integration_methods.pdf

11_Finite_Integration_methods_prime2.0.mcdx

 

Solving a Second Order Differential Equation

This exercise demonstrates changing a second-order differential equation into two first order equations that can be solved by the Runge-Kutta method.

 11_Finite_SecondOrderEqns.xmcd

11_Finite_SecondOrderEqns.mcd

11_Finite_SecondOrderEqns.pdf

11_Finite_SecondOrderEqns_prime2.0.mcdx

 

Derivation of Finite Difference Equations

This exercise uses the Taylor expansion to derive finite-difference methods for solving differential equations. The Runge-Kutta method is derived for the special case of a function depending only upon the independent variable.

11_Finite_Finite_Difference.xmcd

11_Finite_Finite_Difference.mcd

11_Finite_Finite_Difference.pdf

11_Finite_Finite_Difference_prime2.0.mcdx

Ch.12  Circuit Analysis

Circuit Analysis with Complex Variables

In this exercise, we use complex variables for circuit impedances and find the response function for RC low pass, RC high pass, and RLC bandpass filters.

Both the amplitude and the phase of the signals are plotted as a function of frequency.

12_Circuit_Analysis.xmcd

12_Circuit_Analysis.mcd

12_Circuit_Analysis.pdf

12_Circuit_Analysis_prime2.0.mcdx

 

Response of an RC Filter to a Square Wave

In the lab, square waves or timing pulses are often passed through circuits that filter the wave.

In this exercise, we find what a square pulse will look like after passing through a low-pass, a high-pass, and an RLC bandpass filter.

The square wave is represented by sum of Fourier components.

12_Circuit_Square_wave.xmcd

12_Circuit_Square_wave.mcd

12_Circuit_Square_wave.pdf

12_Circuit_Square_wave_prime2.0.mcdx

 

Reducing Noise by Signal Averaging

A signal that is buried in random noise can often be recovered by signal averaging methods.

In this exercise we generate a vector of digitized voltages similar to the vector that would be generated by a digital oscilloscope that is triggered by a synchronizing pulse.

We then show that averaging signals improves the signal-to-noise ratio.

12_Circuit_Signal_Averaging.xmcd

12_Circuit_Signal_Averaging.mcd

12_Circuit_Signal_Averaging.pdf

12_Circuit_Signal_Averaging_prime2.0.mcdx

Ch.13  Particle-in-cell (PIC) methods for plasmas (new in 2011)

The particle-in-cell method was developed to study electrostatic waves, beam-plasma interactions, sheaths, and other phenomena in plasma that require simultaneous solutions to Poisson's equation and the equations of motion for electrons and (sometimes) ions. In the exercises below PIC codes are developed for problems with increasing levels of complexity. 

 

Basic Particle-in-Cell Code for Cold Plasma Oscillations (new in 2011)

This basic code solves Poisson's equation simultaneously with the equations of motion for electrons. An electrostatic wave is made by modulating the electron velocities.

Simplifications include: (1) the ions are assumed to be a uniform neutralizing background and (2) the electrons have no thermal velocity so they do not leave the simulation domain.

13_PIC_code_ESwave.xmcd

13_PIC_code_ESwave.mcd

13_PIC_code_ESwave.pdf

13_PIC_code_ESwave_prime2.0.mcdx

Particle-in-Cell Code for a Cathode Sheath (new in 2011)

This code finds the electrostatic sheath between an emissive cathode and an anode in a vacuum tube. There are no ions.

The code keeps track of the number of electrons in the simulation domain which varies as electrons are emitted from the cathode, return to the cathode, or are lost at the anode.

The anode may have a bias potential.

13_PIC_sheath_18.xmcd

13_PIC_sheath_18.mcd

13_PIC_sheath_18.pdf

13_PIC_sheath_18_prime2.0.mcdx

 

Particle-in-Cell Code for Landau Damping (new in 2011)

This code differs from the one for cold plasma oscillations in that the electrons are given initial velocities chosen from a distribution function.

Periodic boundary conditions are assumed and electrons leaving the simulation domain at one boundary are returned at the other boundary.

An electrostatic wave is launched by modulating the electron density and this wave is observed to damp at approximately the predicted Landau Damping rate.

Plasma wave echoes are observed and the damping is absent for a "top hat" distribution.

13_PIC_Landau_8.xmcd

13_PIC_Landau_8.mcd

13_PIC_Landau_8.pdf

13_PIC_Landau_8_prime2.0.mcdx

Particle-in-Cell Code for Two-Stream Instability (new in 2011)

This code is similar to the Landau Damping code except that the electron distribution function is two oppositely directed streams each described by a Maxwellian distribution with a drift velocity.

13_PIC_Two_Stream_3.xmcd

13_PIC_Two_Stream_3.mcd

13_PIC_Two_Stream_3.pdf

13_PIC_Two_Stream_3_prime2.0.mcdx

Particle-in-Cell Code for Beam Plasma Instability (new in 2011) 

This code is similar to the Landau damping code except that there is an electron beam in addition to the Maxwellian plasma which creates a “bump-on-tail” instability.

13_PIC_Beam_Plasma_5.xmcd

13_PIC_Beam_Plasma_5.mcd

13_PIC_Beam_Plasma_5.pdf

13_PIC_Beam_Plasma_5_prime2.0.mcdx

Mathcad Prime 2.0

·         We have added all the programs we converted to Mathcad's new platform - Prime 2.0.

·         The good: no calculation errors were encountered when checking the converted worksheets.

·         The bad: you can’t do the conversion with your existing version of Mathcad – even Mathcad 15. PTC (the software company) makes you download a 30-day trial version of Mathcad 15 in order to use the converter in Prime. This trial version of Mathcad 15 is version M010. The converter in Prime works ONLY with Mathcad 15 version M010 (the aforementioned trial version).

·         The ugly: installing the Mathcad 15 trial version removes any prior version of Mathcad you might have had on your computer. Once the 30-day trial period expires, you lose the ability to use the old Mathcad and can only use Prime from that point forward. Therefore, you must convert any old Mathcad doc(s) you want within that timeframe. Although nothing happens to your old files if you don’t convert them, once the 30-day trial elapses you will have to again install the Mathcad 15 trial version to perform any conversions. In addition, functionality decreased significantly in Prime and many features are no longer supported. This is explained more thoroughly below.

 

·         Prime 2.0 Documentation: here are useful pdf files

Mathcad_Prime_Installation_Guide.pdf

Mathcad_Prime_Whats_New.pdf

Mathcad_Prime_Migration_Guide.pdf

Mathcad_Prime_RTF.pdf

Mathcad_Prime_Keyboard_Shortcuts.pdf

 

As mentioned in the above pdf files, 'annotations' will appear in a converted worksheet to let you know if there are possible issues related to the conversion. The vast majority of these annotations just point out places where a formatting change was made and can be ignored. However, Prime only annotates a relatively short list of possible issues - many other issues were discovered by going through the exercises. The exercises for chapters 1 through 13 were scrubbed before being posted. Here is what we have so far:

1.      Data and calculations were checked first - formatting might be slightly different but that is all.

2.      Next, we attempted to restore the original layout of the worksheets with regard to content which might have migrated to an adjacent or subsequent page. Prime does not have a print preview option, so be careful before printing anything.

3.      The page numbers and date in the header don't convert. The header box is positioned so near the top of the page that most printers will not print it. The header should be 0.5 in from the top of the page and is not.

4.      Text boxes have lost superscripts and subscripts. So if we said 3 x 1010 in a box, that is changed to 3 x 1010. And if we referred to x2 it became x2. And if we talked about a subscripted variable xj, it became xj.

5.      We put some equations from the Microsoft Equation editor in our Mathcad 15. It is not longer possible to edit these or make new ones.

6.      Our videos in Mathcad 15 don't work in Prime.

7.      Our vector plots in Mathcad 15 don't work in Prime. The vector plot option is gone.

8.      Plot labels are not supported. Axis labels are still available but if you want a plot label then you will need to make a new text box that serves as your plot label.

9.      Results can't be displayed as tables anymore - they are converted to a matrix.

10.  Only one contour plot can be plotted at a time.

11.  Point plots with more than 4,998 points are automatically made into line plots.

12.  Plot tick intervals are usually different after conversion, so you have to change them back.

13.  To be continued...

Visual to help with annotations you might come across:

Annotations in Prime.pdf