Group Abstract Group Abstract

Message Boards Message Boards

0
|
9.4K Views
|
23 Replies
|
14 Total Likes
View groups...
Share
Share this post:

What is the correct ContourPlot here? Where should I assign my parameters?

Posted 8 years ago
Attachments:
23 Replies

Dear Hans,

@Marco: Which is the reason you don't use T22post in

Tpost[kn, a] = 1/(T22*(T22)[Conjugate]);

It is difficult to come up with a credible excuse for my stupid mistake. Sorry!

Best wishes,

Marco

POSTED BY: Marco Thiel
POSTED BY: Hans Dolhaine

The notebook ContourPlot 2.nb

gives the same as the first if you comment out the first three lines (the Clear commands) after second evaluation.

ClearAll doesn't appear to do anything anyway.

I think.

Cheers, Marco

POSTED BY: Marco Thiel
Attachments:
POSTED BY: Hans Dolhaine

If I run

(*ClearAll["Global`*"]*)
(*ClearAll["Global`*"]
ClearAll[Evaluate[$Context<>"*"]]*)

ClearAll["Global`*"];
energy = 0.027*eV;

eV = 1/27.2113845;
nm = 1/0.052917721092;

a0 = 4.65;
n = 0;
M = 4;
W = a0*(3*M + 1);

e = 1;
h = 1;
v = 0.003*137.036;

kmodC = (energy - e*VC)/(h*v);
kmodRG = (energy - e*VRG)/(h*v);
kmodRB = (energy - e*VRB)/(h*v);

kC = (kmodC^2 - kn^2)^0.5;
kRG = (kmodRG^2 - kn^2)^0.5;
kRB = (kmodRB^2 - kn^2)^0.5;

zC = (kn + I*kC)/((kn^2 + kC^2)^0.5);
zRG = (kn + I*kRG)/((kn^2 + kRG^2)^0.5);
zRB = (kn + I*kRB)/((kn^2 + kRB^2)^0.5);


T22 = ( E^(-2 I a (kC + kRG) + 
      I b (2 kRG + kRB)) ((zC zRG - 1)^2 E^(
        4 I (a - b) kRG) (-1 + zRB zRG)^2 + 
       2 E^(2 I (a - b) kRG)  (-zC (1 + zRG^2) + zRG + 
          zC^2 zRG)))/((-1 + zRG^2)^2);

T[kn_, a_] = 1/(T22*(T22)\[Conjugate]);

(*Parameters*)
VRG = 0.100*eV;
VRB = 0.001*eV;
VC = 0.001*eV;
b = (a + d);
d = 50*nm;
(*Parameters*)

T22post = ( 
    E^(-2 I a (kC + kRG) + 
      I b (2 kRG + kRB)) ((zC zRG - 1)^2 E^(
        4 I (a - b) kRG) (-1 + zRB zRG)^2 + 
       2 E^(2 I (a - b) kRG)  (-zC (1 + zRG^2) + zRG + 
          zC^2 zRG)))/((-1 + zRG^2)^2);

Tpost[kn_, a_] = 1/(T22*(T22)\[Conjugate]);

Evaluate[T[kn*(1/nm), (a/2)*nm] === Tpost[kn*(1/nm), (a/2)*nm]]

It turns out that the T and Tpost are not identical as Hans says. The first bits of the functions are a bit different:

T

enter image description here

Post

enter image description here

at the very end the "a" has a different factor.

In principle it is now easy to see what is happening. Just compare

TreeForm[Tpost[kn*(1/nm), (a/2)*nm]]

to

TreeForm[T[kn*(1/nm), (a/2)*nm]]

I agree that the delayed definition would probably be more appropriate.

Best wishes,

Marco

POSTED BY: Marco Thiel

Ok, so what I understand is that, there is something odd happening, the function is definitely not the same depending on how I assign values to my parameters as Marco clearly demonstrated. Both Marco and Hans, you are advicing me to hold any evaluation until the plot. Did I get it right?

You are also suggesting this procedure would give the correct answer. In your opinion, can I really trust this is the case or should I use a different program just to be sure, like Matlab; or will I find the same issue there?

Thanks.

I think the problem is solved. It seems that there were problems with handing the parameters to the function(s). Look at my code ( a modificaton of Marco's code). It gives the same functions regardless where you do the assignments. And in my opinion Mathematica will do the job.

POSTED BY: Hans Dolhaine

Ok, then I'll rest assured that delaying is the correct procedure, Hans. Thank you very much for your time. :)

The thing that intrigues me most is what exactly the definition

T[a_] = K + hv

has got to do with the plot - it is a function of one variable. There

ContourPlot[T[a,b], {a, 0.0,  1.0},  {b, 0.0,  1.0}]

T is a function of two variables. So the definition is inconsequential and should give an empty image, should it not? It therefore appears that T as a function of two variables must be defined somewhere else in the code/notebook. It would be useful to have that definition.

Cheers,

Marco

POSTED BY: Marco Thiel

Yes, both Hans and Marco are totally right. I made a mistake in the example. I apologise for the confusion. I uploaded a 2 working notebooks, however, so it becomes more clear. I also edited that mistake now. Thanks again,

Edit: The notebooks contain a plot of what should be the same function. They vary only on the place where I assign the values of my parameters.

And what is hv?

POSTED BY: Hans Dolhaine

Planck's constant and escape velocity but I'll edit that to make it clearer, thanks for the reply :)

POSTED BY: Hans Dolhaine

This time I was first (even though my post appears below)!

;-)

Marco

POSTED BY: Marco Thiel

smile

POSTED BY: Hans Dolhaine

Simplify[T[a_]] does not simplify the definition of T. For that you must insert Simplify into the definition: T[a_]=Simplify[k+hv].

POSTED BY: Gianluca Gorni

Thank you for the remark Gianluca, I have already edited that mistake.

Posted 8 years ago

I think you'd get more and better responses if you supplied a complete working example. And admittedly I can be a bit dense as I'm not at all certain what the issue is that you're having trouble with.

POSTED BY: Jim Baldwin

Thanks for the comment Jim. Now I can't put the code but I'll try to reproduce this problem with a simpler function and I'll post it as soon as I can.

Posted 8 years ago

I still don't understand what the issue is but a wild guess is that you don't like the fact that parts of one of the contour plots is "white". Usually to fix that one can use PlotRange -> All.

POSTED BY: Jim Baldwin

I'll admit I hate the white spots, haha, but that's not the problem. The problem is that both contour plots that appear above come from the same function (and the same ContourPlot instructions). The order in which I assign values to my parameters alters the plot.

POSTED BY: Marco Thiel
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard