# Unable to plot each matrix element of a matrix differential equation. The variable of differential equation is a 4x4 matrix

I'm trying to implement the von Neumann Equation for a given 4x4 density Matrix with a Hamiltonian in Mathematica. I followed the method in this thread (Von Neumann Equation Density Matrix) but I still couldn't get access to each matrix element of my density matrix. When I use Dimensions[sol] it is giving me {5}. So the solution is not a matrix? I don't understand what is the data type of the solution of NDSolve and how can I plot the all the 16 matrix elements separately with respect to time? My code is attached below. Please help.

h1 = {
{0, \[CapitalOmega], 0, 0},
{\[CapitalOmega], \[CapitalDelta], g, 0},
{0, g, 0, 0},
{0, 0, 0, 0}
};
rhoin = {
{1, 0, 0, 0},
{0, 0, 0, 0},
{0, 0, 0, 0},
{0, 0, 0, 0}
};
tmax = 10;
Clear[rho]
sol = NDSolveValue[{I*rho'[t] == h1 . rho[t] - rho[t] . h1,
rho[0] == rhoin}, rho, {t, 0, tmax}];
Dimensions[sol]


Clear["Global*"];
Ω = .1;
Δ = 1/2;
g = 9.8;
h1 = {{0, Ω, 0, 0}, {Ω, Δ,
g, 0}, {0, g, 0, 0}, {0, 0, 0, 0}};
rhoin = {{1, 0, 0, 0}, {0, 0, 0, 0}, {0, 0, 0, 0}, {0, 0, 0, 0}};
tmax = 10;
sol = NDSolveValue[{I*rho'[t] == (h1 . rho[t] - rho[t] . h1),
rho[0] == rhoin}, rho, {t, 0, tmax}];
sol[.5] // Dimensions
ReImPlot[sol[t], {t, 0, tmax}]


{4, 4}

• Thank you very much for the answer. But how do I plot all 16 {4,4} matrix elements seperatly? If possible I also like to store each of them in some variable and play with it. Is it possible? Thanks a lot. Commented Jul 10, 2022 at 9:11
• @Siddhu For i=2,j=3, use ReImPlot[sol[t][[2, 3]], {t, 0, tmax}]` etc. Commented Jul 10, 2022 at 9:21
• Thanks a lot. It is quite helpful. Commented Jul 10, 2022 at 11:15