Help with loops in Mathematica (Hamiltonian)

Join the discussion
Ask a follow-up here, or get your own question answered by working scientists, mathematicians and engineers — people, not an autocomplete.
Real named experts · corrections over time · the nuance an AI answer skips
2 replies · 2K views
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: 500
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}}