Class WaveFunction1D
- Namespace
- QuantumWaves
- Assembly
- QuantumLibrary.dll
Base class for one dimensional wave functions.
public abstract class WaveFunction1D
- Inheritance
-
WaveFunction1D
- Derived
- Inherited Members
Constructors
WaveFunction1D(FloatRange, ComplexF)
Initializes a new wave function with a domain and amplitude.
protected WaveFunction1D(FloatRange domain, ComplexF amplitude)
Parameters
domainFloatRangeThe spatial domain of the wave function.
amplitudeComplexFThe amplitude of the wave function.
Properties
Amplitude
Gets or sets the amplitude of the wave function.
public ComplexF Amplitude { get; set; }
Property Value
Domain
Gets the spatial domain of the wave function.
public FloatRange Domain { get; protected set; }
Property Value
Methods
Evaluate(float, float)
Evaluates the wave function ψ(x, t).
public ComplexF Evaluate(float x, float t)
Parameters
xfloatThe position at which to evaluate the wave function.
tfloatThe time at which to evaluate the wave function.
Returns
- ComplexF
The value of the wave function at
xandt, or zero ifxis outside the domain.
EvaluateRaw(float, float)
Evaluates the unscaled wave function at (x, t).
protected abstract ComplexF EvaluateRaw(float x, float t)
Parameters
xfloatThe position at which to evaluate the unscaled wave function.
tfloatThe time at which to evaluate the unscaled wave function.
Returns
- ComplexF
The unscaled value of the wave function at
xandt.
IntegrateRaw(float, FloatRange, int)
Integrates the squared magnitude of the unscaled wave function over a range.
protected float IntegrateRaw(float t, FloatRange domain, int intervals = 100000)
Parameters
tfloatThe time at which the raw wave function is evaluated.
domainFloatRangeThe range over which to integrate the raw probability density.
intervalsintThe number of intervals used by Simpson integration.
Returns
- float
The approximate integral of the unscaled probability density over the specified range.
ProbabilityDensity(float, float)
Evaluates the probability density |ψ(x, t)|².
public float ProbabilityDensity(float x, float t)
Parameters
xfloatThe position at which to evaluate the probability density.
tfloatThe time at which to evaluate the probability density.
Returns
- float
The probability density at
xandt.
ProbabilityInRange(float, FloatRange, int)
Approximates the probability over a given range.
public float ProbabilityInRange(float t, FloatRange domain, int intervals = 100000)
Parameters
tfloatThe time at which the probability density is evaluated.
domainFloatRangeThe range over which to integrate the probability density.
intervalsintThe number of intervals used by Simpson integration.
Returns
- float
The approximate probability over the specified range.
Sample(int, out float[], float, int, int, Random?, float, float, int)
Generates random position samples of the wave.
public bool Sample(int sampleCount, out float[] samples, float t = 0, int pointCount = 1000, int segmentIntervals = 8, Random? rng = null, float tolerance = 0.0001, float maxAllowed = 1000000, int maxCount = 10000)
Parameters
sampleCountintThe number of samples to generate. Must be greater than zero.
samplesfloat[]Contains the samples if successful, otherwise an empty array.
tfloatThe time at which the wave function is sampled.
pointCountintThe number of discrete points used to approximate the cumulative distribution. Must be greater than one.
Larger values improve the accuracy of the sampled distribution but increase preprocessing cost.
segmentIntervalsintThe number of Simpson integration intervals used for each cumulative distribution segment. Must be greater than zero.
Larger values improve local integration accuracy but increase computation cost. Simpson integration requires an even number of intervals, odd values are automatically rounded up.
rngRandomThe random number generator used for sampling.
tolerancefloatRelative convergence tolerance for infinite domain expansion. Must be greater than zero.
maxAllowedfloatMaximum allowed integral value. Must be greater than zero.
maxCountintMaximum number of expansion iterations. Must be greater than zero.
Returns
Exceptions
- ArgumentOutOfRangeException
Thrown if
sampleCountis less than or equal to zero,pointCountis less than or equal to one,segmentIntervalsis less than or equal to zero,toleranceis less than or equal to zero,maxAllowedis less than or equal to zero, ormaxCountis less than or equal to zero.
TryNormalize(float, float, float, int)
Attempts to normalize the wave function.
public bool TryNormalize(float t = 0, float tolerance = 0.0001, float maxAllowed = 1000000, int maxCount = 10000)
Parameters
tfloatTime at which normalization is evaluated.
tolerancefloatRelative convergence tolerance for infinite domain expansion.
maxAllowedfloatMaximum allowed integral value.
maxCountintMaximum number of expansion iterations.