Taper issue
clemc98 opened this issue · comments
clemc98 commented
Hi,
I'm experiencing an issue when using the Taper module.
I need to have a tapering between two microstrip with different width.
import numpy as np
from pyems.structure import Microstrip, PCB, MicrostripCoupler
from pyems.simulation import Simulation
from pyems.pcb import common_pcbs
from pyems.calc import phase_shift_length, microstrip_effective_dielectric
from pyems.utilities import print_table, mil_to_mm
from pyems.coordinate import Box2, Box3, Axis, Coordinate2, Coordinate3
from pyems.mesh import Mesh
from pyems.field_dump import FieldDump, DumpType
from pyems.kicad import write_footprint
from pyems.structure import (
PCB,
Microstrip,
common_smd_passives,
SMDPassive,
Taper,
ViaWall,
)
import time
import os
import glob
#The following part is useless regarding my issue, it is just an help to create new folder for simulation
filename="gcpw_taper_v1.1"
timestr= time.strftime("_%Y%m%d_%H%M%S")
sim_dir= filename + timestr
#print(sim_dir)
print("Voulez-vous recalculer la simulation\n Y/N")
answer = input().lower()
print('sans casse : ', answer)
if answer == "y" :
if not os.path.exists(sim_dir):
os.makedirs(sim_dir)
calc_only=False
elif answer == "n" :
calc_only=True
print("la réponse est non")
path ="./"
only_dir = [ name for name in os.listdir(path) if os.path.isdir(os.path.join(path, name)) ]
only_dir.sort(key=os.path.getmtime)
only_dir.reverse()
list_del = [] # on crée ici une liste pour pouvoir supprimer en une seule fois tous les éléments différents de filename* de la liste only_dir
for index, i in enumerate(only_dir) :
if i.startswith(filename)==False:
list_del.append(index)
else :
print(index, i)
list_del.reverse() # on inverse l'ordre de la liste pour avoir les index dans l'ordre décroissant, sinon il y aura des problèmes d'indentation lors de la suppression
for i in list_del :
#print(i,"\n")
only_dir.pop(int(i))
print("Quelle simulation voulez-vous lancer ?\n")
choix=int (input())
sim_dir=only_dir[choix]
print ("Le programme va chercher la simulation dans",sim_dir)
#Here is the usefull code
unit = 1e-3
freq = np.arange(0, 18e9, 1e7)
# freq = np.linspace(4e9, 8e9, 501)
sim = Simulation(freq=freq, unit=unit, end_criteria=1e-2, sim_dir=sim_dir, calc_only=calc_only)
pcb_prop = common_pcbs["oshpark4"]
pcb_len = 10
pcb_width = 5
trace_width = 0.34
gap = mil_to_mm(6)
via_gap = 0.4
z0_ref = 50
cap_dim = common_smd_passives["0402C"]
cap_dim.set_unit(unit)
pad_length = 0.6
pad_width = cap_dim.width
pcb = PCB(
sim=sim,
pcb_prop=pcb_prop,
length=pcb_len,
width=pcb_width,
layers=range(3),
omit_copper=[0],
)
Microstrip1= Microstrip(
pcb=pcb,
position=Coordinate2(-pcb_len/4, 0),
length= pcb_len/8,
width=trace_width,
propagation_axis=Axis("x"),
port_number=1,
excite=True,
ref_impedance=50,
feed_shift=0.3,
)
Microstrip2= Microstrip(
pcb=pcb,
position=Coordinate2(pcb_len/4, 0),
length= pcb_len/8,
width=trace_width*2,
propagation_axis=Axis("x"),
port_number=2,
excite=False,
ref_impedance=50,
feed_shift=0.3,
)
taper = Taper(
pcb=pcb,
position=Coordinate2(0, 0),
pcb_layer=0,
width1=trace_width/2,
width2=trace_width/2,
length=pcb_len/2,
gap=gap,
transform=None,
)
FieldDump(
sim=sim,
box=Box3(
Coordinate3(-pcb_len / 2, -pcb_width / 2, 0),
Coordinate3(pcb_len / 2, pcb_width / 2, 0),
),
dump_type=DumpType.current_density_time,
)
mesh = Mesh(
sim=sim,
metal_res=1 / 120,
nonmetal_res=1 / 40,
smooth=(1.5, 1.5, 1.5),
min_lines=5,
expand_bounds=((8, 8), (8, 8), (8, 8)),
)
sim.run()
sim.view_field()
After running this i have the join issue
issue.md
It's running fine if i put
position=None,
instead of
position=Coordinate2(0, 0),
Have you any suggestions to help me ?
matthuszagh commented
Thanks for filing a report. This was a bug with pyems and should now be fixed with e44451a. Please feel free to reopen if you're still experiencing issues, etc.