Help with loops in Mathematica (Hamiltonian)

Click For Summary
SUMMARY

The discussion focuses on generating a Hamiltonian matrix for the Schrödinger equation using Mathematica. The user aims to create a 7x7 matrix where diagonal elements are defined by ΔE, and off-diagonal elements are determined by the complex conjugate of Ω(rf) based on specific conditions. The proposed solution utilizes the Table function in Mathematica along with KroneckerDelta to establish the matrix elements effectively. The provided code snippet demonstrates the correct implementation of these conditions to achieve the desired matrix structure.

PREREQUISITES
  • Familiarity with Mathematica syntax and functions
  • Understanding of Hamiltonian mechanics in quantum physics
  • Knowledge of matrix operations and properties
  • Basic concepts of complex numbers and conjugates
NEXT STEPS
  • Study the use of the Table function in Mathematica for matrix generation
  • Explore KroneckerDelta and its applications in conditional matrix creation
  • Learn about Hamiltonian operators in quantum mechanics
  • Investigate complex number operations in Mathematica
USEFUL FOR

Students and researchers in physics, particularly those working on quantum mechanics and Hamiltonian systems, as well as developers seeking to implement mathematical models in Mathematica.

vankoks
Messages
1
Reaction score
0

Homework Statement



I have an assignment for my thesis to make Hamiltonian for Schrödinger equation. I won't go into physics part of it, because that is well understood.

I need to somehow generate a specific matrix for Hamiltonian (H).

Please see the attached file of what I need to get.

Homework Equations



See attached file

The Attempt at a Solution



I have thought of solution for this in C, but I don't know how to syntax this in Mathematica.

The solution for this in C would be to generate 7x7 matrix where elements (i,j) would be made by:

If
i=j
ΔE
Else
If
i-j=1
Ω(rf) complex conjugate
i-j=-1
Ω(rf)
Else
0
 

Attachments

  • hamiltonian.png
    hamiltonian.png
    6.6 KB · Views: 493
Physics news on Phys.org
The best way I know is to create a 2D table and use KroneckerDelta to decide the value of each element in the table.
 
In[1]:= H = Table[
Which[
i == j, g*\[Mu]B*ToExpression["m" <> ToString]*B,
i - j == 1, Conjugate[\[CapitalOmega]rf],
i - j == -1, \[CapitalOmega]rf,
True, 0
], {i, 7}, {j, 7}
]

Out[1]= {{B g m1 \[Mu]B, \[CapitalOmega]rf, 0, 0, 0, 0, 0},
{Conjugate[\[CapitalOmega]rf], B g m2 \[Mu]B, \[CapitalOmega]rf, 0, 0, 0, 0},
{0, Conjugate[\[CapitalOmega]rf], B g m3 \[Mu]B, \[CapitalOmega]rf, 0, 0, 0},
{0, 0, Conjugate[\[CapitalOmega]rf], B g m4 \[Mu]B, \[CapitalOmega]rf, 0, 0},
{0, 0, 0, Conjugate[\[CapitalOmega]rf], B g m5 \[Mu]B, \[CapitalOmega]rf, 0},
{0, 0, 0, 0, Conjugate[\[CapitalOmega]rf], B g m6 \[Mu]B, \[CapitalOmega]rf},
{0, 0, 0, 0, 0, Conjugate[\[CapitalOmega]rf], B g m7 \[Mu]B}}
 

Similar threads

  • · Replies 3 ·
Replies
3
Views
4K
  • · Replies 8 ·
Replies
8
Views
2K
  • · Replies 5 ·
Replies
5
Views
4K
  • · Replies 156 ·
6
Replies
156
Views
12K
  • · Replies 1 ·
Replies
1
Views
2K
  • · Replies 1 ·
Replies
1
Views
964
  • · Replies 9 ·
Replies
9
Views
3K
  • · Replies 3 ·
Replies
3
Views
3K
  • · Replies 10 ·
Replies
10
Views
3K
  • · Replies 4 ·
Replies
4
Views
2K