diff --git a/.utils/test.pdf b/.utils/test.pdf new file mode 100644 index 0000000..7cbc240 Binary files /dev/null and b/.utils/test.pdf differ diff --git a/.utils/test.tex b/.utils/test.tex new file mode 100644 index 0000000..e578b05 --- /dev/null +++ b/.utils/test.tex @@ -0,0 +1,93 @@ +\documentclass[11pt]{article} + + +% 页面设置 +\usepackage[top=1cm, bottom=2cm, left=1cm, right=1cm]{geometry} + +% 中文支持 +\usepackage{ctex} + +% 数学包 +\usepackage{amsmath, amssymb, amsthm} + +% 算法包 +\usepackage[linesnumbered, ruled]{algorithm2e} + +\begin{document} + +\title{伪代码test} +\author{test} +\maketitle + +\begin{algorithm}[H] + \caption{Main Routine for Gaussian Elimination Solver} + \label{alg:main_routine} + \KwIn{Input File Path (string), \texttt{tol} (long double), \texttt{max\_iter} (int)} + \KwOut{Solutions (array)} + + \While{True}{ + \texttt{selected\_file} $\gets$ \textit{SelectInputFile}() \tcp*[r]{Select the input file} + \If{\texttt{selected\_file} is empty}{ + \textbf{exit} \tcp*[r]{Exit if no file is selected} + } + + \texttt{start\_time} $\gets$ \textit{StartTimer}() \tcp*[r]{Start the timer} + + \textit{InitMatrix}(\texttt{matrix}, \texttt{selected\_file}, \texttt{rows}, \texttt{cols}) \tcp*[r]{Initialize the matrix} + \textit{ShowEquations}(\texttt{matrix}, \texttt{rows}, \texttt{cols}) \tcp*[r]{Display the system of equations} + + \texttt{exchange\_count} $\gets$ \textit{GaussianElimination}(\texttt{matrix}, \texttt{rows}, \texttt{cols}) \tcp*[r]{Perform Gaussian elimination} + + \texttt{rank} $\gets$ \textit{DetermineRank}(\texttt{matrix}, \texttt{rows}, \texttt{cols}) \tcp*[r]{Determine the rank of the matrix} + \texttt{consistent} $\gets$ \textit{CheckConsistency}(\texttt{matrix}, \texttt{rows}, \texttt{cols}) \tcp*[r]{Check if the system is consistent} + + \If{not \texttt{consistent}}{ + \textit{DisplaySolution}("No solution") \tcp*[r]{Display no solution message} + } + \ElseIf{\texttt{rank} $<$ (\texttt{cols} $-$ 1)}{ + \textit{ShowGeneralSolution}(\texttt{matrix}, \texttt{rows}, \texttt{cols}, \texttt{rank}) \tcp*[r]{Display parameterized solution} + } + \Else{ + \texttt{solution} $\gets$ \textit{BackSubstitution}(\texttt{matrix}, \texttt{rows}, \texttt{cols}, \texttt{solution}) \tcp*[r]{Perform back substitution} + \If{\texttt{solvable}}{ + \textit{DisplaySolution}(\texttt{solution}) \tcp*[r]{Display the unique solution} + } + \Else{ + \textit{DisplaySolution}("No solution") \tcp*[r]{Display no solution if back substitution fails} + } + } + + \textit{StopTimer}(\texttt{start\_time}) \tcp*[r]{Stop the timer} + \texttt{choice} $\gets$ \textit{AskRunAgain}() \tcp*[r]{Ask if the user wants to run again} + \If{\texttt{choice} $\neq$ 'y' \textbf{and} \texttt{choice} $\neq$ 'Y'}{ + \textbf{break} \tcp*[r]{Exit loop if the choice is not 'y' or 'Y'} + } + } + + \textit{WaitForExit}() \tcp*[r]{Wait for program exit} +\end{algorithm} + + + +\begin{algorithm}[H] + \caption{Pivoting to Select the Maximum Element in a Column} + \label{alg:pivoting} + \KwIn{$\texttt{matrix}$ (Matrix), $\texttt{current\_row}$ (int), $\texttt{total\_rows}$ (int)} + \KwOut{$\texttt{imax}$ (int)} + + \texttt{imax} $\gets$ \texttt{current\_row}\; + \texttt{max\_val} $\gets$ $|\texttt{matrix}[\texttt{current\_row}][\texttt{current\_row}]|$\; + \For{$i \gets \texttt{current\_row} + 1$ \textbf{to} $\texttt{total\_rows} - 1$}{ + \texttt{val} $\gets$ $|\texttt{matrix}[i][\texttt{current\_row}]|$\; + \If{\texttt{val} $>$ \texttt{max\_val}}{ + \texttt{imax} $\gets$ $i$\; + \texttt{max\_val} $\gets$ \texttt{val}\; + } + } + \Return \texttt{imax}\; +\end{algorithm} + + + + +\end{document} \ No newline at end of file diff --git a/Assignment_3/Problem_3/src/documenter_output/build/.documenter-siteinfo.json b/Assignment_3/Problem_3/src/documenter_output/build/.documenter-siteinfo.json index 9b9c039..1c21dd5 100644 --- a/Assignment_3/Problem_3/src/documenter_output/build/.documenter-siteinfo.json +++ b/Assignment_3/Problem_3/src/documenter_output/build/.documenter-siteinfo.json @@ -1 +1 @@ -{"documenter":{"julia_version":"1.10.5","generation_timestamp":"2024-10-09T13:20:21","documenter_version":"1.7.0"}} \ No newline at end of file +{"documenter":{"julia_version":"1.10.5","generation_timestamp":"2024-10-11T16:23:08","documenter_version":"1.7.0"}} \ No newline at end of file diff --git a/Assignment_3/Problem_3/src/documenter_output/build/index.html b/Assignment_3/Problem_3/src/documenter_output/build/index.html index 2bb7b2f..be9e4db 100644 --- a/Assignment_3/Problem_3/src/documenter_output/build/index.html +++ b/Assignment_3/Problem_3/src/documenter_output/build/index.html @@ -1,2 +1,2 @@ -Home · SchrödingerSolver Documentation
+Home · SchrödingerSolver Documentation
diff --git a/Assignment_3/Problem_3/src/documenter_output/build/interaction.html b/Assignment_3/Problem_3/src/documenter_output/build/interaction.html index 851937f..1234e85 100644 --- a/Assignment_3/Problem_3/src/documenter_output/build/interaction.html +++ b/Assignment_3/Problem_3/src/documenter_output/build/interaction.html @@ -1,8 +1,8 @@ -Interaction · SchrödingerSolver Documentation

Interaction Module

This module handles interaction and plotting functions to display and visualize results.

Main.SchrödingerSolver.Interaction.plot_wavefunctionsMethod
plot_wavefunctions(
+Interaction · SchrödingerSolver Documentation

Interaction Module

This module handles interaction and plotting functions to display and visualize results.

Main.SchrödingerSolver.Interaction.plot_wavefunctionsMethod
plot_wavefunctions(
     x_vals::AbstractVector{Float64},
     wavefunctions::Vector{Vector{Float64}},
     num_levels::Int,
     potential_name::String,
     potential_params::Vector{Float64}
-)

Plots the wave functions.

Arguments

  • x_vals: Values of x.
  • wavefunctions: Precomputed and normalized wave functions.
  • num_levels: Number of energy levels to plot.
  • potential_name: The name of the potential function.
  • potential_params: Coefficients for the polynomial potential function.
source
+)

Plots the wave functions.

Arguments

  • x_vals: Values of x.
  • wavefunctions: Precomputed and normalized wave functions.
  • num_levels: Number of energy levels to plot.
  • potential_name: The name of the potential function.
  • potential_params: Coefficients for the polynomial potential function.
source
diff --git a/Assignment_3/Problem_3/src/documenter_output/build/methods.html b/Assignment_3/Problem_3/src/documenter_output/build/methods.html index 647e25b..1a91238 100644 --- a/Assignment_3/Problem_3/src/documenter_output/build/methods.html +++ b/Assignment_3/Problem_3/src/documenter_output/build/methods.html @@ -1,2 +1,2 @@ -Methods · SchrödingerSolver Documentation

Methods Module

This module provides methods for solving integrals and other calculations.

Main.SchrödingerSolver.Methods.build_matricesMethod
build_matrices(N, v, s, potential_gaussian_integral, potential_params)

Builds the Hamiltonian matrix H and overlap matrix S for the variational method.

Arguments

  • N: Number of basis functions.
  • v: Width parameters of the Gaussian basis functions.
  • s: Centers of the Gaussian basis functions.
  • potential_gaussian_integral: Function to compute the potential energy integral.
  • potential_params: Additional parameters for the potential function.

Returns

  • (H, S): The Hamiltonian and overlap matrices.
source
Main.SchrödingerSolver.Methods.kinetic_integralMethod
kinetic_integral(v1, s1, v2, s2)

Computes the kinetic energy integral between two Gaussian basis functions.

The kinetic energy integral is given by:

\[T_{ij} = \frac{v_1^{3/2} v_2^{3/2} \left( v_1 + v_2 - 2 v_1 v_2 (s_1 - s_2)^2 \right)}{\sqrt{\pi} (v_1 + v_2)^{5/2}} e^{- \frac{v_1 v_2 (s_1 - s_2)^2}{v_1 + v_2}}\]

Arguments

  • v1: Width parameter of the first Gaussian basis function.
  • s1: Center of the first Gaussian basis function.
  • v2: Width parameter of the second Gaussian basis function.
  • s2: Center of the second Gaussian basis function.

Returns

  • T_ij: The kinetic energy integral value.
source
Main.SchrödingerSolver.Methods.overlap_integralMethod
overlap_integral(v1, s1, v2, s2)

Computes the overlap integral between two Gaussian basis functions with parameters (v1, s1) and (v2, s2).

The overlap integral is given by:

\[S_{ij} = \frac{\sqrt{v_1 v_2}}{\sqrt{\pi (v_1 + v_2)}} e^{- \frac{v_1 v_2 (s_1 - s_2)^2}{v_1 + v_2}}\]

Arguments

  • v1: Width parameter of the first Gaussian basis function.
  • s1: Center of the first Gaussian basis function.
  • v2: Width parameter of the second Gaussian basis function.
  • s2: Center of the second Gaussian basis function.

Returns

  • S_ij: The overlap integral value.
source
Main.SchrödingerSolver.Methods.potential_integral_xnMethod
potential_integral_xn(v1, s1, v2, s2, n)

Computes the potential energy integral for ( V(x) = x^n ) between two Gaussian basis functions.

Arguments

  • v1, s1: Parameters of the first Gaussian basis function.
  • v2, s2: Parameters of the second Gaussian basis function.
  • n: The power of x in the potential function (integer from 0 to 4).

Returns

  • V_ij: The potential energy integral value.
source
Main.SchrödingerSolver.Methods.solve_schrodingerMethod
solve_schrodinger(H, S, num_levels)

Solves the generalized eigenvalue problem for the Hamiltonian H and overlap matrix S.

Arguments

  • H: Hamiltonian matrix.
  • S: Overlap matrix.
  • num_levels: Number of energy levels to compute.

Returns

  • (energies, states): The lowest num_levels eigenvalues and eigenvectors.
source
+Methods · SchrödingerSolver Documentation

Methods Module

This module provides methods for solving integrals and other calculations.

Main.SchrödingerSolver.Methods.build_matricesMethod
build_matrices(N, v, s, potential_gaussian_integral, potential_params)

Builds the Hamiltonian matrix H and overlap matrix S for the variational method.

Arguments

  • N: Number of basis functions.
  • v: Width parameters of the Gaussian basis functions.
  • s: Centers of the Gaussian basis functions.
  • potential_gaussian_integral: Function to compute the potential energy integral.
  • potential_params: Additional parameters for the potential function.

Returns

  • (H, S): The Hamiltonian and overlap matrices.
source
Main.SchrödingerSolver.Methods.kinetic_integralMethod
kinetic_integral(v1, s1, v2, s2)

Computes the kinetic energy integral between two Gaussian basis functions.

The kinetic energy integral is given by:

\[T_{ij} = \frac{v_1^{3/2} v_2^{3/2} \left( v_1 + v_2 - 2 v_1 v_2 (s_1 - s_2)^2 \right)}{\sqrt{\pi} (v_1 + v_2)^{5/2}} e^{- \frac{v_1 v_2 (s_1 - s_2)^2}{v_1 + v_2}}\]

Arguments

  • v1: Width parameter of the first Gaussian basis function.
  • s1: Center of the first Gaussian basis function.
  • v2: Width parameter of the second Gaussian basis function.
  • s2: Center of the second Gaussian basis function.

Returns

  • T_ij: The kinetic energy integral value.
source
Main.SchrödingerSolver.Methods.overlap_integralMethod
overlap_integral(v1, s1, v2, s2)

Computes the overlap integral between two Gaussian basis functions with parameters (v1, s1) and (v2, s2).

The overlap integral is given by:

\[S_{ij} = \frac{\sqrt{v_1 v_2}}{\sqrt{\pi (v_1 + v_2)}} e^{- \frac{v_1 v_2 (s_1 - s_2)^2}{v_1 + v_2}}\]

Arguments

  • v1: Width parameter of the first Gaussian basis function.
  • s1: Center of the first Gaussian basis function.
  • v2: Width parameter of the second Gaussian basis function.
  • s2: Center of the second Gaussian basis function.

Returns

  • S_ij: The overlap integral value.
source
Main.SchrödingerSolver.Methods.potential_integral_xnMethod
potential_integral_xn(v1, s1, v2, s2, n)

Computes the potential energy integral for ( V(x) = x^n ) between two Gaussian basis functions.

Arguments

  • v1, s1: Parameters of the first Gaussian basis function.
  • v2, s2: Parameters of the second Gaussian basis function.
  • n: The power of x in the potential function (integer from 0 to 4).

Returns

  • V_ij: The potential energy integral value.
source
Main.SchrödingerSolver.Methods.solve_schrodingerMethod
solve_schrodinger(H, S, num_levels)

Solves the generalized eigenvalue problem for the Hamiltonian H and overlap matrix S.

Arguments

  • H: Hamiltonian matrix.
  • S: Overlap matrix.
  • num_levels: Number of energy levels to compute.

Returns

  • (energies, states): The lowest num_levels eigenvalues and eigenvectors.
source
diff --git a/Assignment_3/Problem_3/src/documenter_output/build/utils.html b/Assignment_3/Problem_3/src/documenter_output/build/utils.html index f21e606..62f7bd1 100644 --- a/Assignment_3/Problem_3/src/documenter_output/build/utils.html +++ b/Assignment_3/Problem_3/src/documenter_output/build/utils.html @@ -1,2 +1,2 @@ -Utils · SchrödingerSolver Documentation

Utils Module

The Utils module includes utility functions that assist with data processing, normalization, and parameter handling.

Main.SchrödingerSolver.Utils.get_parametersMethod
get_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.
source
Main.SchrödingerSolver.Utils.get_potential_functionMethod
get_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.
source
Main.SchrödingerSolver.Utils.normalize_wavefunctionMethod
normalize_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.
source
Main.SchrödingerSolver.Utils.read_intMethod
read_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.
source
Main.SchrödingerSolver.Utils.read_numberMethod
read_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.
source
+Utils · SchrödingerSolver Documentation

Utils Module

The Utils module includes utility functions that assist with data processing, normalization, and parameter handling.

Main.SchrödingerSolver.Utils.get_parametersMethod
get_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.
source
Main.SchrödingerSolver.Utils.get_potential_functionMethod
get_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.
source
Main.SchrödingerSolver.Utils.normalize_wavefunctionMethod
normalize_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.
source
Main.SchrödingerSolver.Utils.read_intMethod
read_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.
source
Main.SchrödingerSolver.Utils.read_numberMethod
read_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.
source