[Tutor] I try to convert a MATLAB program to Python...
Henri Heinonen
henri.heinonen at mbnet.fi
Tue Nov 16 08:35:17 CET 2010
These are the four (out of eight) first results I get with the MATLAB code:
----
>> nonhomog(0.2)
nonhomog: using 300 grid points.
BC1_disc_left =
-4.8436e-12
BC1_disc_right =
-1.1027e-13
BC2_disc_left =
-1.1269e-11
BC2_disc_right =
-1.8657e-13
lambda =
0.9976
V0 =
79.0637
nonhomog: using 300 grid points.
BC1_disc_left =
8.5855e-12
BC1_disc_right =
-1.4955e-13
BC2_disc_left =
-9.4851e-12
BC2_disc_right =
3.7053e-12
lambda =
0.9969
V0 =
79.0637
nonhomog: using 300 grid points.
BC1_disc_left =
-4.2669e-12
BC1_disc_right =
-3.8908e-15
BC2_disc_left =
-1.0330e-10
BC2_disc_right =
8.6403e-13
lambda =
0.5464
V0 =
79.0606
nonhomog: using 300 grid points.
BC1_disc_left =
2.9082e-12
BC1_disc_right =
-5.5045e-15
BC2_disc_left =
-8.5076e-13
BC2_disc_right =
3.7712e-13
lambda =
-54.3440
V0 =
78.6880
----
These are the four results I get with my Python code:
----
python nonhomog.py
kappa = 15.7079632679
alpha = 0
nu = 0.2
nx_ = 300
BC1_disc_left = (nan+nanj)
BC1_disc_right = (nan+nanj)
BC2_disc_left = (nan+nanj)
BC2_disc_right = (nan+nanj)
lambda = -0.774244159818
nonhomog.py:81: DeprecationWarning: integer argument expected, got float
xx = range(-kappa, h, kappa+1)
kappa = 15.7079632679
alpha = 5.80527619798e-06
nu = 0.2
nx_ = 300
BC1_disc_left = (nan+nanj)
BC1_disc_right = (nan+nanj)
BC2_disc_left = (nan+nanj)
BC2_disc_right = (nan+nanj)
lambda = -0.774244180107
kappa = 15.7079632679
alpha = 0.000580527619798
nu = 0.2
nx_ = 300
BC1_disc_left = (nan+nanj)
BC1_disc_right = (nan+nanj)
BC2_disc_left = (nan+nanj)
BC2_disc_right = (nan+nanj)
lambda = -0.774246188696
kappa = 15.7079632679
alpha = 0.0580527619798
nu = 0.2
nx_ = 300
BC1_disc_left = (nan+nanj)
BC1_disc_right = (nan+nanj)
BC2_disc_left = (nan+nanj)
BC2_disc_right = (nan+nanj)
lambda = -0.774447043715
----
Some questions:
1. For example, the sign of the lambdas are wrong not to mention that the
values are not even near the corresponding MATLAB values. How to fix these?
2. Also, I get those annoying (nan+nanj) messages for BC1s and BC2s. What's
wrong?
3. There is also this error message: "nonhomog.py:81: DeprecationWarning:
integer argument expected, got float
xx = range(-kappa, h, kappa+1)". How should I fix that?
Thanks!
Henri.
2010/11/16 Henri Heinonen <henri.heinonen at mbnet.fi>
> Hi!
>
> Can you, please, try to help me with Python? I try to convert a MATLAB
> program to Python.
>
> Here are the MATLAB codes:
> http://pastebin.com/MbPZ8Z7X
> http://pastebin.com/dDnF5AF2
>
> Here is my Python code:
> http://pastebin.com/jCPdLHx7
>
> What is wrong with my Python code? The program doesn't produce quite the
> same lambdas as the MATLAB program does.
>
> Thanks for all the help!
>
> Henri.
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/tutor/attachments/20101116/2a9b1b36/attachment.html>
More information about the Tutor
mailing list