72
Canonical Grid model
Physics starter - Quantum
Infinite square well with explicit negative off-diagonals; validate physical eigenvectors as well as eigenvalues.
- Scale
- Small
- Source
- physics-quantum.grid
- Length
- 62 lines
- Collection
- Advanced language
- Level
- Intermediate
- Runtime
- Portable
- Version
- 1.0.0
MODEL "Physics starter - Quantum"
DESCRIPTION "Infinite square well with explicit negative off-diagonals; validate physical eigenvectors as well as eigenvalues."
VERSION "1.0.0"
AUTHOR "Grid Team"
TAGS "physics", "starter", "quantum"
# Infinite square well H=-d^2/dx^2, width=WellWidth, fixed energy scale hbar^2/(2m)=1; energies vary as 1/width^2.
input WellWidth = 1
VALIDATE BETWEEN 0.5 AND 2 MESSAGE "Use a positive well width from 0.5 to 2."
output ExactGround = PI()^2 / WellWidth^2
Hamiltonian_20 = MAKEARRAY(20,20,(row,col) => row=col THEN 2*(21 / WellWidth)^2 ELSE (ABS(row-col)=1 THEN -((21 / WellWidth)^2) ELSE 0))
output Spectrum_20 = EIGEN.VALUES(Hamiltonian_20)
output Ground_20 = MIN(Spectrum_20)
output DiscreteGround_20 = 4*(21 / WellWidth)^2*SIN(PI()/(2*21))^2
Hamiltonian_40 = MAKEARRAY(40,40,(row,col) => row=col THEN 2*(41 / WellWidth)^2 ELSE (ABS(row-col)=1 THEN -((41 / WellWidth)^2) ELSE 0))
output Spectrum_40 = EIGEN.VALUES(Hamiltonian_40)
output Ground_40 = MIN(Spectrum_40)
output DiscreteGround_40 = 4*(41 / WellWidth)^2*SIN(PI()/(2*41))^2
output Eigenvectors = EIGEN.VECTORS(Hamiltonian_20)
# Scientific checks and interpretation
GroundVector = MAKEARRAY(20, 1, (row, col) => INDEX(Eigenvectors, row, 20))
SineReference = MAKEARRAY(20, 1, (row, col) => SQRT(2 / 21) * SIN(PI() * row / 21))
output PhysicalGroundOverlap = ABS(SUMPRODUCT(GroundVector, SineReference))
output OffDiagonal = INDEX(Hamiltonian_20, 1, 2)
AppliedGround = MMULT(Hamiltonian_20, GroundVector)
output EigenResidual = MAX(MAP(SEQUENCE(20), (row) => ABS(INDEX(AppliedGround, row, 1) - Ground_20 * INDEX(GroundVector, row, 1))))
Orientation = SIGN(SUMPRODUCT(GroundVector, SineReference))
output GroundProfile = MAKEARRAY(20, 3, (row, col) => col = 1 THEN row * WellWidth / 21
ELSE col = 2 THEN Orientation * INDEX(GroundVector, row, 1)
ELSE INDEX(SineReference, row, 1))
output Assumptions = "Infinite square well with explicit negative off-diagonals; validate physical eigenvectors as well as eigenvalues. Solver completion alone does not establish global accuracy or physical validity."
output ScenarioGuide = "Save a Baseline input scenario, change an admitted input, inspect numerical checks and the unsmoothed plot, then restore Baseline. Save and reopen a .gridoc archive. Plot selection also accepts the GroundProfile numeric array; choose its X and Y columns in the chart dialog."
Charts_1!type = "charts"
Charts_1!config = <toml>
version = 1
kind = "charts"
title = "Quantum"
[layout]
x_axis = "Position"
y_axis = "Euclidean-normalized amplitude"
[[charts]]
type = "line"
smooth = false
bind = "GroundProfile"
x = "0"
y = "1"
label = "Ground eigenvector"
color = "#2563eb"
[[charts]]
type = "line"
smooth = false
bind = "GroundProfile"
x = "0"
y = "2"
label = "Sine reference"
color = "#d97706"
</toml>
END MODEL