Package HAL.GridsAndAgents
Class PDEGrid1D
- java.lang.Object
-
- HAL.GridsAndAgents.PDEGrid1D
-
- All Implemented Interfaces:
Grid1D
,java.io.Serializable
public class PDEGrid1D extends java.lang.Object implements Grid1D, java.io.Serializable
a 1D- See Also:
- Serialized Form
-
-
Method Summary
Modifier and Type Method Description void
Add(double x, double val)
void
Add(int x, double val)
adds to the prev field value at the specified indexvoid
AddAll(double val)
adds specified value to all entries of the delta fieldvoid
Advection(double xVel)
void
Advection(double[] xVels)
runs discontinuous advectionvoid
Advection(double[] xVels, Coords1DDouble BoundaryConditionFn, Coords1DDouble BoundaryXvel)
runs discontinuous advectionvoid
Advection(double xVel, double boundaryValue)
runs advection as described above with a boundary value, meaning that the boundary value will advect in from the upwind direction, and the concentration will disappear in the downwind direction.void
Advection(double xVel, Coords1DDouble BoundaryConditionFn)
runs advection as described above with a boundary condition function, which will be evaluated with the out of bounds coordinates as arguments whenever a boundary value is needed, and should return the boundary valuevoid
Advection(Grid2Ddouble xVels)
runs discontinuous advectionvoid
Advection(Grid2Ddouble xVels, Coords1DDouble BoundaryConditionFn, Coords1DDouble BoundaryXvel)
runs discontinuous advectionvoid
Diffusion(double diffCoef)
runs diffusion on the current field, adding the deltas to the delta field.void
Diffusion(double[] diffRates)
runs diffusion with discontinuous diffusion ratesvoid
Diffusion(double[] diffRates, Coords1DDouble BoundaryConditionFn, Coords1DDouble BoundaryDiffusionRateFn)
runs diffusion with discontinuous diffusion ratesvoid
Diffusion(double diffCoef, double boundaryValue)
has the same effect as the above diffusion function without the boundary value argument, except rather than assuming zero flux, the boundary condition is set to either the boundaryValue, or wrap aroundvoid
Diffusion(double diffCoef, Coords1DDouble BoundaryConditionFn)
has the same effect as the above diffusion function with a boundary condition function, which will be evaluated with the out of bounds coordinates as arguments whenever a boundary value is needed, and should return the boundary valuevoid
Diffusion(Grid1Ddouble diffRates)
runs diffusion with discontinuous diffusion ratesvoid
Diffusion(Grid1Ddouble diffRates, Coords1DDouble BoundaryConditionFn, Coords1DDouble BoundaryDiffusionRateFn)
runs diffusion with discontinuous diffusion ratesvoid
DiffusionCrank(double diffCoef)
void
DiffusionCrank(double diffCoef, Coords1DDouble BC)
double
Get(double x)
double
Get(int x)
gets the prev field value at the specified coordinatesdouble
GetAvg()
gets the average value of all squares in the current fielddouble[]
GetDeltas()
double[]
GetField()
boolean
IsWrapX()
int
Length()
double
MaxDelta()
returns the maximum difference as stored on the delta field, call right before calling Update()double
MaxDeltaScaled(double denomOffset)
like MaxDelta only the differences are scaled relative to the value in the current field.void
Mul(double x, double val)
void
Mul(int x, double val)
multiplies a value in the “current field” and adds the change to the “delta field”void
MulAll(double val)
multiplies all values in the “current field” and puts the results into the “delta field”void
Set(double x, double val)
void
Set(int x, double val)
sets the prev field value at the specified coordinatesvoid
SetAll(double val)
sets all squares in the delta field to the specified valuevoid
SetAll(double[] vals)
sets all squares in the delta field using the vals arrayvoid
SetNonNegative()
ensures that all values will be non-negative on the next timestep, call before Updatevoid
Update()
adds the delta field into the current field, also increments the tick.int
UpdateCt()
int
Xdim()
-
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface HAL.Interfaces.Grid1D
ApplyHood, ApplyHoodMapped, ApplyRectangle, ContainsValidI, DispX, Dist, DistSquared, GetHoodI, In, In, InWrap, InWrap, MapHood, MapHood, MapXpt, MapXsq, RandomHoodI, WrapI
-
-
-
-
Method Detail
-
GetField
public double[] GetField()
-
GetDeltas
public double[] GetDeltas()
-
Get
public double Get(int x)
gets the prev field value at the specified coordinates
-
Get
public double Get(double x)
-
Set
public void Set(int x, double val)
sets the prev field value at the specified coordinates
-
Set
public void Set(double x, double val)
-
Add
public void Add(int x, double val)
adds to the prev field value at the specified index
-
Add
public void Add(double x, double val)
-
Mul
public void Mul(int x, double val)
multiplies a value in the “current field” and adds the change to the “delta field”
-
Mul
public void Mul(double x, double val)
-
Update
public void Update()
adds the delta field into the current field, also increments the tick.
-
UpdateCt
public int UpdateCt()
-
Advection
public void Advection(double xVel)
-
Advection
public void Advection(double xVel, double boundaryValue)
runs advection as described above with a boundary value, meaning that the boundary value will advect in from the upwind direction, and the concentration will disappear in the downwind direction.
-
Advection
public void Advection(double xVel, Coords1DDouble BoundaryConditionFn)
runs advection as described above with a boundary condition function, which will be evaluated with the out of bounds coordinates as arguments whenever a boundary value is needed, and should return the boundary value
-
Advection
public void Advection(double[] xVels)
runs discontinuous advection
-
Advection
public void Advection(Grid2Ddouble xVels)
runs discontinuous advection
-
Advection
public void Advection(double[] xVels, Coords1DDouble BoundaryConditionFn, Coords1DDouble BoundaryXvel)
runs discontinuous advection
-
Advection
public void Advection(Grid2Ddouble xVels, Coords1DDouble BoundaryConditionFn, Coords1DDouble BoundaryXvel)
runs discontinuous advection
-
DiffusionCrank
public void DiffusionCrank(double diffCoef)
-
DiffusionCrank
public void DiffusionCrank(double diffCoef, Coords1DDouble BC)
-
Diffusion
public void Diffusion(double diffCoef)
runs diffusion on the current field, adding the deltas to the delta field. This form of the function assumes either a reflective or wrapping boundary (depending on how the PDEGrid was specified). the diffCoef variable is the nondimensionalized diffusion conefficient. If the dimensionalized diffusion coefficient is x then diffCoef can be found by computing (x*SpaceStep)/TimeStep^2 Note that if the diffCoef exceeds 0.5, this diffusion method will become numerically unstable.
-
Diffusion
public void Diffusion(double diffCoef, double boundaryValue)
has the same effect as the above diffusion function without the boundary value argument, except rather than assuming zero flux, the boundary condition is set to either the boundaryValue, or wrap around
-
Diffusion
public void Diffusion(double diffCoef, Coords1DDouble BoundaryConditionFn)
has the same effect as the above diffusion function with a boundary condition function, which will be evaluated with the out of bounds coordinates as arguments whenever a boundary value is needed, and should return the boundary value
-
Diffusion
public void Diffusion(double[] diffRates)
runs diffusion with discontinuous diffusion rates
-
Diffusion
public void Diffusion(Grid1Ddouble diffRates)
runs diffusion with discontinuous diffusion rates
-
Diffusion
public void Diffusion(double[] diffRates, Coords1DDouble BoundaryConditionFn, Coords1DDouble BoundaryDiffusionRateFn)
runs diffusion with discontinuous diffusion rates
-
Diffusion
public void Diffusion(Grid1Ddouble diffRates, Coords1DDouble BoundaryConditionFn, Coords1DDouble BoundaryDiffusionRateFn)
runs diffusion with discontinuous diffusion rates
-
SetAll
public void SetAll(double val)
sets all squares in the delta field to the specified value
-
MulAll
public void MulAll(double val)
multiplies all values in the “current field” and puts the results into the “delta field”
-
SetAll
public void SetAll(double[] vals)
sets all squares in the delta field using the vals array
-
AddAll
public void AddAll(double val)
adds specified value to all entries of the delta field
-
GetAvg
public double GetAvg()
gets the average value of all squares in the current field
-
MaxDelta
public double MaxDelta()
returns the maximum difference as stored on the delta field, call right before calling Update()
-
MaxDeltaScaled
public double MaxDeltaScaled(double denomOffset)
like MaxDelta only the differences are scaled relative to the value in the current field. the denomOffset is used to prevent a division by zero
-
SetNonNegative
public void SetNonNegative()
ensures that all values will be non-negative on the next timestep, call before Update
-
-