Patch Antenna code? Aurel Registered Offline This member has written at least 317 posts and created at least 29 threads on this forum since joining inApr 2017. 12-11-2017, 03:26 AM Finally i get some time to try tis python program before i start translation to BASIC. And i install python2.5 i think for windows.. also i tried few programs from examples and seems to me that work. Ok then i copy /paste code for patch antenna here: Code:```import math from math import cos, sin, sqrt, atan2, acos def PatchFunction(thetaInDeg, phiInDeg, Freq, W, L, h, Er): """ Taken from Design_patchr Calculates total E-field pattern for patch as a function of theta and phi Patch is assumed to be resonating in the (TMx 010) mode. E-field is parallel to x-axis W......Width of patch (m) L......Length of patch (m) h......Substrate thickness (m) Er.....Dielectric constant of substrate Refrence C.A. Balanis 2nd Edition Page 745 """ lamba = 3e8 / Freq theta_in = math.radians(thetaInDeg) phi_in = math.radians(phiInDeg) ko = 2 * math.pi / lamba xff, yff, zff = sph2cart1(999, theta_in, phi_in) # Rotate coords 90 deg about x-axis to match array_utils coord system with coord system used in the model. xffd = zff yffd = xff zffd = yff r, thp, php = cart2sph1(xffd, yffd, zffd) phi = php theta = thp if theta == 0: theta = 1e-9 # Trap potential division by zero warning if phi == 0: phi = 1e-9 Ereff = ((Er + 1) / 2) + ((Er - 1) / 2) * (1 + 12 * (h / W)) ** -0.5 # Calculate effictive dielectric constant for microstrip line of width W on dielectric material of constant Er F1 = (Ereff + 0.3) * (W / h + 0.264) # Calculate increase length dL of patch length L due to fringing fields at each end, giving total effective length Leff = L + 2*dL F2 = (Ereff - 0.258) * (W / h + 0.8) dL = h * 0.412 * (F1 / F2) Leff = L + 2 * dL Weff = W # Calculate effective width Weff for patch, uses standard Er value. heff = h * sqrt(Er) # Patch pattern function of theta and phi, note the theta and phi for the function are defined differently to theta_in and phi_in Numtr2 = sin(ko * heff * cos(phi) / 2) Demtr2 = (ko * heff * cos(phi)) / 2 Fphi = (Numtr2 / Demtr2) * cos((ko * Leff / 2) * sin(phi)) Numtr1 = sin((ko * heff / 2) * sin(theta)) Demtr1 = ((ko * heff / 2) * sin(theta)) Numtr1a = sin((ko * Weff / 2) * cos(theta)) Demtr1a = ((ko * Weff / 2) * cos(theta)) Ftheta = ((Numtr1 * Numtr1a) / (Demtr1 * Demtr1a)) * sin(theta) # Due to groundplane, function is only valid for theta values : 0 < theta < 90 for all phi # Modify pattern for theta values close to 90 to give smooth roll-off, standard model truncates H-plane at theta=90. # PatEdgeSF has value=1 except at theta close to 90 where it drops (proportional to 1/x^2) to 0 rolloff_factor = 0.5 # 1=sharp, 0=softer theta_in_deg = theta_in * 180 / math.pi # theta_in in Deg F1 = 1 / (((rolloff_factor * (abs(theta_in_deg) - 90)) ** 2) + 0.001) # intermediate calc PatEdgeSF = 1 / (F1 + 1) # Pattern scaling factor UNF = 1.0006 # Unity normalisation factor for element pattern if theta_in <= math.pi / 2: Etot = Ftheta * Fphi * PatEdgeSF * UNF # Total pattern by pattern multiplication else: Etot = 0 return Etot def sph2cart1(r, th, phi): x = r * cos(phi) * sin(th) y = r * sin(phi) * sin(th) z = r * cos(th) return x, y, z def cart2sph1(x, y, z): r = sqrt(x**2 + y**2 + z**2) + 1e-15 th = acos(z / r) phi = atan2(y, x) return r, th, phi```then anfter that i get stupid error about indent ??? what a heck is that what indent ??? one of reasons why I dont like python program stuck because syntax error look in screenshot... and what is end of indent? what i nightmare for me this time ... Attached Files Thumbnail(s) basicPro forum: http://basicpro.mipropia.com/smf/index.php EU Radioboard forum: http://euradioboard.createmybb3.com/index.php AurelSoft main site: http://aurelsoft.ucoz.com bplus B = B + ... Offline This member has written at least 1,268 posts and created at least 154 threads on this forum since joining inApr 2017. 12-11-2017, 03:51 AM Why don't you translate it to a Basic say O2 that you are much more familiar? (Assuming you understand the meanings for all the parameters in the 3 functions defined above, otherwise why bother at all?) B += x Aurel Registered Offline This member has written at least 317 posts and created at least 29 threads on this forum since joining inApr 2017. 12-11-2017, 05:37 AM Yes why,simply because i am not sure that this code show what I want or what is supposed to be : electric current density on metal patch surface... so first I want to see Is work properly or not? by the way maybe i can try function by function test in let say Creative Basic first because tzhaz way is easyer than in o2 hmmm such a crap all that pyhon coding basicPro forum: http://basicpro.mipropia.com/smf/index.php EU Radioboard forum: http://euradioboard.createmybb3.com/index.php AurelSoft main site: http://aurelsoft.ucoz.com Aurel Registered Offline This member has written at least 317 posts and created at least 29 threads on this forum since joining inApr 2017. 12-15-2017, 05:26 AM ....AND by the way where is this show-man FIGOSDEV - mennonite ? when he left forum? and why ? hmm maybe again no one likes him or something like that ..gee basicPro forum: http://basicpro.mipropia.com/smf/index.php EU Radioboard forum: http://euradioboard.createmybb3.com/index.php AurelSoft main site: http://aurelsoft.ucoz.com Aurel Registered Offline This member has written at least 317 posts and created at least 29 threads on this forum since joining inApr 2017. 12-19-2017, 04:57 AM This post was last modified: 12-19-2017, 04:57 AM by Aurel.Edited 0 times AHH i see figosdev- easylangs-mennonite spending time on net54 forum COME HERE menn! right now and show your knowlege about python for a real thing! basicPro forum: http://basicpro.mipropia.com/smf/index.php EU Radioboard forum: http://euradioboard.createmybb3.com/index.php AurelSoft main site: http://aurelsoft.ucoz.com « Next Oldest | Next Newest » 