Преглед изворни кода

Progress on p1, still not done

There's still something I'm not understanding about how to do this. I've
literally never seen an asymetric potential well before.
Pjotir пре 4 недеља
родитељ
комит
f3f584d6dc
1 измењених фајлова са 10 додато и 1 уклоњено
  1. 10 1
      Homework3/problem1_potentialwell.m

+ 10 - 1
Homework3/problem1_potentialwell.m

@@ -6,4 +6,13 @@ m = 1;
 v1 = 30;
 v2 = 40;
 L = 1;
-N = 1000;
+N = 10;
+x_min = -5; x_max = 5; x = linspace(x_min, x_max, N);
+dx = x(2) - x(1);
+
+diagonal_k = 2*ones(N, 1)
+off_diagonal_k = -1*ones(N-1, 1)
+laplacian = diag(diagonal_k) + diag(off_diagonal_k, 1) + diag(off_diagonal_k, -1)
+laplacian = laplacian / dx^2
+kinetic = -(hbar^2 / (2*m)) * laplacian
+potential = spdiags(v1, 0, N, N)