pysces

pysces.PIB(x, L, n)[source]
Parameters
  • x – a variable.

  • L – Length of the box.

  • n – an integer.

Returns

The WaveFunction for Particle in a Box with respect to the chosen parameters.

pysces.PIB_2D(x, y, L_x, L_y, n)[source]
Parameters
  • x – a variable.

  • y – a variable.

  • L_x – Length of the box in the x direction

  • L_y – Length of the box in the y direction

  • n – an integer.

Returns

The WaveFunction for Particle in a Box in two dimensions with respect to the chosen parameters.

pysces.PIB_2D_normalized(x, y, L_x, L_y, n)[source]
Parameters
  • x – a variable.

  • y – a variable.

  • L_x – Length of the box in the x direction

  • L_y – Length of the box in the y direction

  • n – an integer.

Returns

The normalized WaveFunction for Particle in a Box, with respect to the chosen variables. This answer at this time cannot be calculated using the normalization_constant() function.

pysces.PIB_normalized(x, L, n)[source]
Parameters
  • x – a variable.

  • L – Length of the box.

  • n – an integer.

Returns

The normalized WaveFunction for Particle in a Box, with respect to the chosen variables. This answer can also be calculated using the normalization_constant() function.

pysces.a_lowering(A=None)[source]
Parameters
  • A – this is usually either empty, (no parameter), “normalized” for the normalized ladder operator,

  • a "symbol" for the symbolic representation of the parameter. (or) –

Returns

Either the mathematic representation of the “a” lowering operator (commonly used in harmonic oscillator problems), the normalized lowering operator (in dirac notation), or the symbol notation of the operator.

pysces.a_raising(A=None)[source]
Parameters
  • A – this is usually either empty, (no parameter), “normalized” for the normalized ladder operator, or a “symbol” for the symbolic

  • of the parameter. (representation) –

Returns

Either the mathematic representation of the “a” raising operator (commonly used in harmonic oscillator problems), the normalized raising operator (in dirac notation), or the symbol notation of the operator.

pysces.ang_mom_2(ang_mom, mag)[source]
Parameters
  • ang_mom – The total angular momentum quantum number

  • mag – The magnetic quantum number

Returns

The L^2 vector magnitude eigenvalue for spherical harmonics.

Note

Bra(str(j), str(“,”), str(m))*j*(j+1)*h_b**2*Ket(str(j), str(“,”), str(m))

pysces.ang_mom_lowering(ang_mom=None, mag=None)[source]
Parameters
  • ang_mom – The total angular momentum quantum number

  • mag – The magnetic quantum number

Returns

If ang_mom == None and mag== None, the general formula for the lowering operator for spherical harmonics is returned. Else, the formula for the lowering operator is computed using Dirac notation

Note

Bra(str(j), str(“,”), str(m))*h_b*sqrt(j*(j+1)-m*(m-1))*Ket(str(j), str(‘,’), str(m-1))

pysces.ang_mom_raising(ang_mom=None, mag=None)[source]
Parameters
  • ang_mom – The total angular momentum quantum number

  • mag – The magnetic quantum number

Returns

If ang_mom == None and mag == None, the general formula for the raising operator for spherical harmonics is returned. Else, the formula for the raising operator is computed using Dirac notation

Note

Bra(str(j), str(“,”), str(m))*h_b*sqrt(j*(j+1)-m*(m+1))*Ket(str(j), str(‘,’), str(m+1))

\[\langle j, m | \hbar \sqrt{ j (j+1) - m (m+1) } | j, m+1 \rangle\]
pysces.ang_mom_x(ang_mom=None, mag=None)[source]
Parameters
  • ang_mom – The total angular momentum quantum number

  • mag – The magnetic quantum number

Returns

If ang_mom == None and mag == None, the general formula for the L_x operator for spherical harmonics is returned. Else, the formula for the L_x operator is computed using Dirac notation

pysces.ang_mom_z(ang_mom, mag)[source]
Parameters
  • ang_mom – The total angular momentum quantum number

  • mag – The magnetic quantum number

Returns

The L_z projection (in the z direction) eigenvalue for spherical harmonics.

Note

Bra(str(j), str(“,”), str(m))*m*h_b*Ket(str(j), str(“,”), str(m))

pysces.comm_1(commutator_1, commutator_2, aux)[source]

This function is not used directly, it is only used in the comm() function below.

Parameters
  • commutator_1 – The first operator in the commutator

  • commutator_2 – The second operator in the commutator

  • aux – The auxiliary function. This is defined below, as F(x).

Returns

The commutator of commutator_1 and commutator_2 with respect to the auxiliary function.

pysces.comm_steps(commutator_1, commutator_2, aux)[source]
Parameters
  • commutator_1 – the first operator

  • commutator_2 – the second operator

  • aux – the auxiliary function

Returns

Three main steps used to solve a commutator. The first is the printed commutator in brackets, the second is the expansion, and the third output will be the answer. Please note that as of now, the code does not understand the addition/subtraction/multiplication/division of commutators, and so if there are multiple commutators in a line (ex: comm_steps(comm(A, B) - comm(C, D))) the code will not process this and therefore each individual commutator needs to have its own line.

pysces.conjugate(expr)[source]
Parameters

x – The term of interest. This is commonly a WaveFunction.

Returns

The complex conjugate of a WaveFunction. If there are imaginary terms, they get negated, and if there are no imaginary terms, the WaveFunction is not affected.

pysces.expectation_value(wavefunc_1, operator, wavefunc_2, lower, upper, var)[source]

Computes a symbolic expression for an expectation value of an operator operator with the two wavefunctions: <WaveFunc_1|operator|WaveFunc_2>

Parameters
  • wavefunc_1 – The “bra” normalized WaveFunction

  • operator – The operator of interest

  • wavefunc_2 – The “ket” normalized WaveFunction

  • lower – The lower bound of the integral. If bounds are not listed, this is -oo

  • upper – The upper bound of the integral. If bounds are not listed, this is oo

  • var – What the integral is taken with respect to

Returns

The expectation value for the given operator and normalized WaveFunction. An expectation value is the average value of an operator for a given WaveFunction.

pysces.expectation_value_steps(wavefunc_1, operator, wavefunc_2, lower, upper, var)[source]

Computes a symbolic expression for an expectation value of an operator operator with the two wavefunctions: <WaveFunc_1|operator|WaveFunc_2>

Parameters
  • wavefunc_1 – The “bra” normalized WaveFunction

  • operator – The operator of interest

  • wavefunc_2 – The “ket” normalized WaveFunction

  • lower – The lower bound of the integral. If bounds are not listed, this is -oo

  • upper – The upper bound of the integral. If bounds are not listed, this is oo

  • var – What the integral is taken with respect to

Returns

The steps on how to solve an expectation value problem. An expectation value is the average value of an operator for a given WaveFunction.

pysces.expression_replace(expr, var)[source]

This is only used within the “comm()” function.

expression_replace(expr, var)

Parameters
  • expr – The expanded commutator to be replaced

  • var – The variable/parameter with respect to the chosen commutator.

Returns

This replaces the Derivative(1, x) present in the expanded commutator with either Derivative(F(x), x) or Derivative(x*F(x), x).

Note

The above states “x”, but can be done for x, y, or z variables. The “expr” parameter is a str()

pysces.f(var)[source]
Parameters
  • var – This is what the auxiliary function is with respect to. It should also match the parameters of the other arguments in the

  • function. (example (comm()) – if one operator is lin_mom(y), the auxiliary function should be f(y).

Returns

This is the auxiliary function, commonly used in the comm() function. This simply returns “f(x)”, x being with chosen parameter.

pysces.factorization(expr, var)[source]
Parameters
  • expr – the expression of interest

  • var – the variable of interest. This is most likely going to be the same variable used in the auxiliary function.

Returns

The simplified commutator. This is only used when both of the operators in the commutator are angular momentum operators.

pysces.fixed_gaussian(alpha, x_0, p)[source]
Parameters
  • alpha – alpha parameter of the gaussian

  • x_0 – x_0 parameter of the gaussian

  • p – p parameter of the gaussian

Returns

The moving gaussian wave function.

pysces.hamiltonian(var)[source]
Parameters

var – The variable for the given function. This is usually “x”, “y” or “z”.

Returns

The Hamiltonian operator, made up of the kinetic energy operator and the general potential energy operator.

pysces.harmonic(condition=None)[source]
Parameters

condition – the condition of the harmonic oscillator. Examples include: “ground_state” or “ladder”. This can also be left blank to give the general definition of a harmonic oscillator.

Returns

The Harmonic Oscillator Hamiltonian. Note that “p” is the linear momentum operator, and so the first term is the kinetic_energy() function mentioned above.

pysces.kinetic_energy(var=None)[source]
Parameters

var – The variable in which the derivative is with respect to.

Returns

The kinetic energy operator, with respect to the chosen parameter.

Note

The “1” in the derivative is a placeholder, which will be replaced. If var == None, the general linear operator is printed, with all three positional arguments “x”, “y”, and “z”

pysces.kronecker(i, j)[source]
Parameters
  • i – this is usually “i” and the first variable of the kronecker delta.

  • j – this is usually given a numerical value, and is the second variable of the kronecker delta.

Returns

https://github.com/liz-stippell/Pysces

Return type

This function does not print anything, but instead is used in conjunction with the code found in the kronecker_delta file on

pysces.laguerre(r, n)[source]
Parameters
  • r – What the equation is with respect to. This is commonly “r” or “x”

  • n – The principle Quantum Number

Returns

The Laguerre polynomial. This is commonly used to solve the laguerre_assoc() function.

pysces.laguerre_2(r, n)[source]
Parameters
  • r – What the equation is with respect to. This is commonly “r” or “x”

  • n – The principle Quantum Number

Returns

The Laguerre polynomial, without simplification and without the derivative computed.

pysces.laguerre_assoc(n, l)[source]
Parameters
  • n – The principle Quantum Number

  • l – The angular momentum Quantum Number

Returns

The Laguerre Associated polynomial, commonly used to solve the radial function.

pysces.lin_mom(var=None)[source]
Parameters

var – The variable that the linear momentum operator is with respect to.

Returns

The linear momentum operator, with respect to the parameter.

Note

The “1” in the derivative is a placeholder, which will be replaced. If var == None, the general linear operator is printed, with all three positional arguments “x”, “y”, and “z”

pysces.moving_gaussian(alpha, x_0, p)[source]
Parameters
  • alpha – alpha parameter of the gaussian

  • x_0 – x_0 parameter of the gaussian

  • p – p parameter of the gaussian

Returns

The moving gaussian wave function.

pysces.moving_gaussian_normalized(alpha, gamma, x_0, p_0)[source]
Parameters
  • alpha – alpha parameter of the normalized gaussian

  • gamma – gamma parameter of the normalized gaussian

  • x_0 – x_0 parameter of the normalized gaussian

  • p_0 – p_0 parameter of the normalized gaussian

Returns

The normalized gaussian WaveFunction, with respect to the chosen variables.

pysces.normalization_constant(wavefunc, lower, upper, var1, var2=None)[source]
Parameters
  • wavefunc – The WaveFunction/expression of interest

  • lower – The lower bound of the integral. If bounds are not listed, this is -oo

  • upper – The upper bound of the integral. If bounds are not listed, this is oo

  • var1 – What the integral is taken with respect to

  • var2 – What the second integral is taken with respect to

Returns

The normalization constant, with respect to the given parameters. To find the normalized WaveFunction, the output for normalization_constant() must be multiplied by the original WaveFunction. A normalized WaveFunction indicates that the probability of finding a particle within certain bounds must be equal to one.

Note

The double integration only works if they are integrated over the same bounds.

pysces.normalization_constant_steps(wavefunc, lower, upper, var1, var2=None)[source]
Parameters
  • wavefunc – The WaveFunction/expression of interest

  • lower – The lower bound of the integral. If bounds are not listed, this is -oo

  • upper – The upper bound of the integral. If bounds are not listed, this is oo

  • var1 – What the (first) integral is taken with respect to

  • var2 – What the second integral is taken with respect to (if there are two integrals)

Returns

The steps on how to solve a normalization problem.

pysces.overlap(WaveFunc_1, WaveFunc_2, lower, upper, var)[source]

Computes a symbolic expression for an overlap of two functions, <WaveFunc_1|WaveFunc_2>

Parameters
  • WaveFunc_1 – The “bra” normalized WaveFunction

  • WaveFunc_2 – The “ket” normalized WaveFunction

  • var – What the integral is taken with respect to

  • lower – The lower bound of the integral. If bounds are not listed, this is -oo

  • upper – The upper bound of the integral. If bounds are not listed, this is oo

Returns

The overlap of the two WaveFunctions of interest over given bounds.

pysces.planewave(x)[source]
Parameters

x – What the function is with respect to.

Returns

The PlaneWave function with respect to the parameter.

pysces.plot_function(func, lower1, upper1, B, lower2=None, upper2=None, C=None)[source]
Parameters
  • func – The function/Normalized WaveFunction of interest

  • lower – The lower bound of the B domain (for Particle in a Box, 0)

  • upper – The upper bound of the B domain (for Particle in a Box, 1)

  • B – This is “x” usually (x-axis) - the domain

  • lower2 – The lower bound for the C range (for Particle in a Box, 0)

  • upper2 – The upper bound for the C range (for Particle in a Box, 1)

  • C – This is “y” usually (y-axis) - the range

Returns

A plotted function of the function/Normalized WaveFunction of interest.

Note

The cell often has to be run TWICE in order to print the plot/graph.

pysces.potential_energy(var)[source]
Parameters

var – The variable for the given function. This is usually “x”, “y” or “z”.

Returns

The general potential energy operator, v(x)

pysces.simplify_ladder(expr)[source]
Parameters

expr – the expression of interest

Returns

The simplified expression, replacing any a_rasing(symbol)**2 with 0, a_lowering(symbol)**2 with 0, and 2*a_raising(symbol)*a_lowering(symbol) with (2*n+1).

Note

The code does not “understand” the difference between a_raising(symbol)*a_lowering(symbol) and a_lowering(symbol)*a_raising(symbol) which are mathematically different and produce different outcomes.

pysces.spherical(expr)[source]
Parameters

expr – The expression of interest to be changed into spherical coordinates

Returns

The expression of interest, A, in terms of spherical coordinates

pysces.x_ladder()[source]
Parameters
  • this time (At) –

  • are no parameters necessary. (there) –

Returns

“x” with respect to the “a” raising/lowering operators