Class MCPSolution

java.lang.Object
  extended bySolution
      extended byParticleSolution
          extended byMCPSolution
Direct Known Subclasses:
MCPDrawSolution

public class MCPSolution
extends ParticleSolution

Solves the equation with a Monte Carlo method.

Version:
$Revision: 1.34 $
See Also:
Solution

Field Summary
protected  boolean distributionUpToDate
          Whether the distribution function is up to date
protected  int numberOfParticles
          The number of test particles in the simulation
protected  double particleDensity
          The amount of mass each test particle represents
protected  double[] particlePosition
          A vector with the position of the particles
protected  java.util.Random random
          Random number generator
 
Fields inherited from class Solution
df, dfm, dfp, dg, dgm, dgp, dh, dhm, dhp, dx, f, f0, fm, fp, g, gm, gp, h, hm, hp, ic, initialMoments, mesh, method, pde, s, scheme, sm, sp, time, x, x_0, x_1, xOffset, xSize, y_0, y_1, yOffset, ySize
 
Constructor Summary
MCPSolution(RunData runData)
          Creates a MCPSolution object.
 
Method Summary
 void discretize(ShapeFunction function)
          Discretize the initial Shape function and initialize the moments Initializes a new set of particles, the number being determined by the numerical scheme parameter.
protected  void generateDistribution()
          Generates the distribution function from the set of test particles.
 double getValue(double arg)
          Linear interpolation of the solution.
 double getValue(int index)
          Gives the value of the function for an index
 boolean hasOption(java.lang.String option)
          Tells whether the solution implements a option
 double[] limits()
          Calculates the limits of the solution.
 double momentsDeviation(int m)
          Calculates the deviation from the m:th initial moment.
 boolean next(RunData runData, PhysData physData)
          Advance the solution forward one step in time.
 void plot(java.awt.Canvas plotArea, java.awt.Image offScrImage, boolean headers)
          Plots the solution
 boolean previous(RunData runData, PhysData physData)
          Take the solution backward one step to initialize 3 time level schemes; not appropriate in this context.
 
Methods inherited from class Solution
calculateMoments, getTime, getWinSize, incTime, measure, output, rescale, setIC, setMethod, setPde, setScheme, setTime, updateHeaders
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

numberOfParticles

protected int numberOfParticles
The number of test particles in the simulation


particlePosition

protected double[] particlePosition
A vector with the position of the particles


particleDensity

protected double particleDensity
The amount of mass each test particle represents


distributionUpToDate

protected boolean distributionUpToDate
Whether the distribution function is up to date


random

protected java.util.Random random
Random number generator

Constructor Detail

MCPSolution

public MCPSolution(RunData runData)
Creates a MCPSolution object. Note that discretize must be called before next is called for the first time.

Parameters:
runData - The run time parameters
See Also:
Solution.next(RunData, PhysData), Solution.discretize(ShapeFunction)
Method Detail

next

public boolean next(RunData runData,
                    PhysData physData)
Advance the solution forward one step in time. The equation is set by the internal variable pde and the numerical scheme by the internal variable scheme

Specified by:
next in class Solution
Parameters:
runData - List of run parameters
physData - Physical parameters (e.g. potential)
Returns:
True if a scheme is implemented for that equation
See Also:
RunData

hasOption

public boolean hasOption(java.lang.String option)
Tells whether the solution implements a option

Specified by:
hasOption in class Solution
Parameters:
option - The the option to implement
Returns:
True if the option is implemented
See Also:
jbone.pdeNames, jbone.schemeNames

plot

public void plot(java.awt.Canvas plotArea,
                 java.awt.Image offScrImage,
                 boolean headers)
Plots the solution

Overrides:
plot in class Solution
Parameters:
plotArea - The plot area
offScrImage - The off screen image to draw on
headers - Whether to draw headers

previous

public boolean previous(RunData runData,
                        PhysData physData)
Take the solution backward one step to initialize 3 time level schemes; not appropriate in this context.

Specified by:
previous in class Solution
Parameters:
runData - List of run parameters
Returns:
False since it is not used here
See Also:
RunData

discretize

public void discretize(ShapeFunction function)
Discretize the initial Shape function and initialize the moments Initializes a new set of particles, the number being determined by the numerical scheme parameter.

Specified by:
discretize in class Solution
Parameters:
function - The initial shape to be approximated
See Also:
Solution.setScheme(java.lang.String)

momentsDeviation

public double momentsDeviation(int m)
Calculates the deviation from the m:th initial moment.

Overrides:
momentsDeviation in class Solution
Parameters:
m - The order of the moment
Returns:
The deviation of the m:th moment from the beginning

limits

public double[] limits()
Calculates the limits of the solution.

Overrides:
limits in class Solution
Returns:
A vector consisting of {min(solution), max(solution)}

getValue

public double getValue(int index)
Gives the value of the function for an index

Overrides:
getValue in class Solution
Parameters:
index - The index for which to get the value
Returns:
The value of the distribution function at a given index

getValue

public double getValue(double arg)
Linear interpolation of the solution. Assumes a uniform mesh.

Overrides:
getValue in class Solution
Parameters:
arg - Argument
Returns:
A linear interpolation of the function for a given argument

generateDistribution

protected void generateDistribution()
Generates the distribution function from the set of test particles. Assumes a uniform mesh.