Utils Module
The Utils module includes utility functions that assist with data processing, normalization, and parameter handling.
Main.SchrödingerSolver.Utils.check_positive_v
— Methodcheck_positive_v(v)
Checks if v
is positive.
Arguments
v
: Value to check.
Throws
Error
ifv <= 0
.
Main.SchrödingerSolver.Utils.get_parameters
— Methodget_parameters(choice::String)
Retrieves parameters based on the user's selection.
Arguments
choice
: User selection for the potential type.
Returns
(N, v, s, potential_gaussian_integral, potential_params, potential_name, num_levels)
: Parameters for solving the Schrödinger equation.
Main.SchrödingerSolver.Utils.get_potential_function
— Methodget_potential_function(choice::String)
Selects the potential function based on user's choice.
Arguments
choice
: User selection for the potential type.
Returns
[(potential_gaussian_integral, potential_name, potential_params)]
: Potential function and parameters.
Main.SchrödingerSolver.Utils.normalize_wavefunction
— Methodnormalize_wavefunction(x_vals::AbstractVector{Float64}, ψ::AbstractVector{Float64})::Vector{Float64}
Normalizes the wave function ψ
based on the integration over x_vals
.
Arguments
x_vals
: Vector of x values.ψ
: Wave function to normalize.
Returns
- Normalized wave function.
Main.SchrödingerSolver.Utils.read_int
— Methodread_int(prompt::String, default::Int)
Reads an integer from the user with a prompt. If the user presses enter without input, returns the default value.
Arguments
prompt
: The prompt message to display.default
: The default value to return if no input is provided.
Returns
- The user-entered integer or the default value.
Main.SchrödingerSolver.Utils.read_number
— Methodread_number(prompt::String, default::Float64)
Reads a floating-point number from the user with a prompt. If the user presses enter without input, returns the default value.
Arguments
prompt
: The prompt message to display.default
: The default value to return if no input is provided.
Returns
- The user-entered number or the default value.
Main.SchrödingerSolver.Utils.trapezoidal_integration
— Methodtrapezoidal_integration(x, y)
Performs trapezoidal integration of y
with respect to x
.
Arguments
x
: Vector of x values.y
: Vector of y values.
Returns
integral
: The result of the integration.