Hello everyone,
I am new to python and i am stuck with this code.
for a fixed value of kr it was working fine but
i wan to put kr in a for loop.
but each time i get this error
For kr in range(1, 5)
^
SyntaxError: invalid syntax
i put the whole code which uses kr in the for loop of kr
but it doesn't work. -
...................................................................................................................
-
# This example computes the diffraction from a superhydrophobic optical grating
-
# immersed in water. A curved liquid-gas interface spans each groove.
-
-
-
from mrcwa import *
-
from tables import *
-
-
# dimensionless curvature of the interface
-
-
-
#Variable
-
M1=0
-
M2=0
-
M3=0
-
-
# groove width
-
g = 5.0
-
# wall width
-
w = 3.0
-
# depth
-
h = 6
-
# period
-
T = g + w
-
r = 0.5 * g
-
#Materials definition
-
air = material(1.0)
-
water = material(1.33,'blue')
-
Si = material((4.367+0.079j),'black')
-
output_file = open("SuperHydro_varying_kr","w")
-
-
For kr in range(1, 5)
-
-
R=r/kr
-
l = R * sqrt( 1 - r**2 / R**2 )
-
zeta = R * ( 1 - sqrt( 1 - r**2 / R**2 ) )
-
-
if kr < 0:
-
-
box + halfspace(-inf, 0.0, Si)
-
box + rectangle(g, h, air, (0, -0.5*h) )
-
box + circle(R, water, (.0,-l))
-
-
ymesh = hstack( ( array([0.0,r]), arange(r+h+zeta-d, h+r+d, d), array([h+g]) ) )
-
print 'good'
-
elif kr > 0:
-
-
box + circle(R, air, (.0,-l))
-
box + halfspace(-inf, 0.0, Si)
-
box + rectangle(g, h, air, (0, -0.5*h) )
-
-
ymesh = hstack( ( array([0.0,r]), arange(r+h-d, h+g+d, d) ) )
-
-
xmesh = hstack( (arange(0,g+0.01,0.001), array([T]) ) )
-
grating=stack( box.slice(xmesh=xmesh, ymesh=ymesh) )
-
print 'bad'
-
M1=0
-
M2=0
-
M3=0
-
M =-50
-
P = 50
-
-
grating.order=(M,P+1)
-
-
grating.l = 0.488
-
-
grating.fourier()
-
-
angles = arange(30,87,1)
-
orders = arange(M,P+1)
-
-
-
for i,theta in enumerate(angles):
-
grating.theta = theta
-
grating.wavevec()
-
grating.partialr()
-
L=grating.partialr()[49]*grating.partialr()[49]
-
Q=grating.partialr()[50]*grating.partialr()[50]
-
S=grating.partialr()[51]*grating.partialr()[51]
-
M1+=L
-
M2+=Q
-
M3+=S
-
output_file.write(" %s %s %s %s \n" % (kr, M1, M2, M3) )
-
output_file.close()
.................................................. .................................................. ...............
2 1697 bvdet 2,851
Expert Mod 2GB
Python keyword for cannot be capitalized! Upper and lower case in Python makes a difference.
thanx its working now :))
Sign in to post your reply or Sign up for a free account.
Similar topics
by: Brian Jones |
last post by:
I'm sure the solution may be obvious, but this problem is driving me
mad. The following is my code:
class a(object):
mastervar =
def __init__(self):
print 'called a'
|
by: Alexander Zatvornitskiy |
last post by:
Hello All!
I'am novice in python, and I find one very bad thing (from my point of view) in
language. There is no keyword or syntax to declare variable, like 'var' in
Pascal, or special syntax in...
|
by: Hansan |
last post by:
Hi all.
I am working on a webpage where I use python and html.
When I want to send one variable to a new script/page I use the following
code:
0) print '''<input type=hidden name="eventid"...
|
by: James A. Donald |
last post by:
I am contemplating getting into Python, which is used by engineers I
admire - google and Bram Cohen, but was horrified to read
"no variable or argument declarations are necessary."
Surely that...
|
by: Graham |
last post by:
This has to do with class variables and instances variables.
Given the following:
<code>
class _class:
var = 0
#rest of the class
|
by: Josiah Manson |
last post by:
I found that I was repeating the same couple of lines over and over in
a function and decided to split those lines into a nested function
after copying one too many minor changes all over. The only...
|
by: neeebs |
last post by:
Hi,
I'm not sure if this is a javascript problem per se, but here goes. I have an xsl document with a python function defined within a <script> block. Elsewhere in the xsl file, within a python...
|
by: Stephen Cattaneo |
last post by:
Hello all,
I am attempting to execute an automated test (written in Python) via
cron. I have to check the HOSTNAME variable as part of the test, oddly
under cron the HOSTNAME environment...
|
by: Cameron Simpson |
last post by:
On 17Aug2008 21:25, John Nagle <nagle@animats.comwrote:
Because $HOSTNAME is a bash specific variable, set by bash but NOT
EXPORTED! Like $0 and a bunch of other "private" variables, subprocesses...
|
by: Timothy Grant |
last post by:
On Fri, Aug 29, 2008 at 12:48 AM, Alexis Boutillier
<alexis.boutillier@arteris.comwrote:
http://docs.python.org/ref/import.html
--
Stand Fast,
tjg.
|
by: DolphinDB |
last post by:
Tired of spending countless mintues downsampling your data? Look no further!
In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
|
by: isladogs |
last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM).
In this month's session, we are pleased to welcome back...
|
by: Vimpel783 |
last post by:
Hello!
Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
|
by: jfyes |
last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
|
by: ArrayDB |
last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
|
by: PapaRatzi |
last post by:
Hello,
I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
|
by: CloudSolutions |
last post by:
Introduction:
For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
|
by: Defcon1945 |
last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
|
by: Faith0G |
last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
| |