0
$\begingroup$

I'm trying to animate plot:enter image description here
a, A, B and C are constants. So I wrote the following script:

a:=1;
E1:=1.6*10^(-19);
E2:=1.6*10^(-19);
E3:=1.6*10^(-19);
h = 6.63*10^-34;
f[x_,t_] = (Sqrt[a]/2) (((10/16) Sin[Pi (x/a)])/E^(I (E1 (t/h)))
            - ((5/16) Sin[3 Pi (x/a)])/E^(I (E2 (t/h)))
            + ((1/16) Sin[5 Pi (x/a)])/E^(I (E3 (t/h))));
Animate[Plot[f[x,t],{x,0,a}, Filling ->Bottom, AxesLabel ->Automatic],
        {t,0,100, 1},AnimationRunning->False]


I get empty graph. Okay, maybe my function is not right, so I've tried f[x_,t_] = Sin(x*t); And again, the graph is empty. What am I doing wrong?

$\endgroup$
  • 1
    $\begingroup$ Don’t use _ in the animate $\endgroup$ – Carl Woll Dec 21 '17 at 18:03
  • 1
    $\begingroup$ you need to define h and also as @CarlWoll pointed, use f[x,t] inside Plot. Also make sure f[x,t] returns real value. $\endgroup$ – Sumit Dec 21 '17 at 18:08
  • $\begingroup$ @Sumit h isn't defined as Planck constant? $\endgroup$ – Russiancold Dec 21 '17 at 18:10
  • 1
    $\begingroup$ @Russiancold you should define the Planck constant as hbar = UnitConvert@Quantity[None, "PlanckConstant"] if you want to use its numerical value. $\endgroup$ – José Antonio Díaz Navas Dec 21 '17 at 18:18
  • 2
    $\begingroup$ h isn't defined as Planck constant? Mathematica does not know that h is supposed to be Planck constant. You can do ?h to find out. Also, if it were, Mathematica uses UpperCase for such things. $\endgroup$ – Nasser Dec 21 '17 at 18:18
1
$\begingroup$

Assuming that you are trying to see the superposition of three different wavefunctions here is your answer.

a = 1;
E1 = 1.6*10^(-19);
E2 = 2.6*10^(-19);
E3 = 3.6*10^(-19);
h =  6.63*10^-34;
f[x_, t_] := (Sqrt[a]/ 2) (((10/16) Sin[Pi (x/a)])/ E^(I (E1 (t/h)))
               - ((5/16) Sin[3 Pi (x/a)])/ E^(I (E2 (t/h))) 
               + ((1/16) Sin[5 Pi (x/a)])/E^(I (E3 (t/h))));

Animate[Plot[Abs[f[x, t]]^2, {x, 0, a}, Filling -> Bottom, PlotRange -> {0, 0.25},
        AxesLabel -> Automatic], {t, 0, 100, 1}, AnimationRunning -> False]

enter image description here

To make sure f[x,t] returns real value I use Abs[] in the Plot. If E1=E2=E3 then you will not see any variation in time.

As José Antonio Díaz Navas pointed out, you can set the value of Planck's constant h by QuantityMagnitude@UnitConvert@Quantity[None, "PlanckConstant"] as well.

$\endgroup$
  • $\begingroup$ Thanks, so comparing to my script you removed "_" and defined h to make it work, right? Why Abs[] but not Re[]? $\endgroup$ – Russiancold Dec 21 '17 at 18:27
  • $\begingroup$ Your function f[x,t] is complex. It is up to you to choose the real part, $\Re$ Re[], and/or the imaginary part, $\Im$ Im[], or Abs[] $\endgroup$ – José Antonio Díaz Navas Dec 21 '17 at 18:32
  • $\begingroup$ That's due to my quantum mechanical habit of using $|/Psi|^2$ :) $\endgroup$ – Sumit Dec 21 '17 at 18:35
  • $\begingroup$ @Sumit it's just my misunderstanding of Abs, somehow I forgot what is absolute value of complex number. Of course I need Abs but not Real part here. $\endgroup$ – Russiancold Dec 21 '17 at 18:37
  • $\begingroup$ @Sumit is there any way to make the animation smoother or it's caused by this certain function? I'm trying to change dt param, but animation is still rough. Btw it's psi-function) $\endgroup$ – Russiancold Dec 21 '17 at 19:04

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.