Best Python code snippet using localstack_python
proj.py
Source:proj.py
...184 return roughnessConstructor(*args)185 except AttributeError:186 print("Warning: unsupported surface roughness type %s. Roughness will be ignored." % roughnessTypeString)187 return None188 def _create_parameter(self,iParName,iFormula,iNotes,iUserEditable,fixGridAxis=""):189 if getSessionVersion(self.session) >= 2:190 self.session.create_parameter(iParName,iFormula,iNotes,iUserEditable,fixGridAxis)191 return192 try:193 self.session.create_parameter(iParName,iFormula,iNotes,iUserEditable)194 except AttributeError:195 empro.activeProject.parameters.append(iParName,iFormula,iNotes,iUserEditable)196 if fixGridAxis in ['X','Y','Z']:197 gG = empro.activeProject.gridGenerator198 newFP = empro.libpyempro.mesh.FixedPoint()199 if fixGridAxis == 'X':200 location = (iParName,0,0)201 elif fixGridAxis == 'Y':202 location = (0,iParName,0)203 elif fixGridAxis == 'Z':204 location = (0,0,iParName)205 newFP.location = location206 newFP.axes=fixGridAxis207 gG.addManualFixedPoint(newFP)208 def _circularGridRegion(self,x,y,radius):209 radius = empro.core.Expression(radius)210 newGRP = empro.libpyempro.mesh.ManualGridRegionParameters()211 newGRP.cellSizes.target = (radius,radius,0)212 newGRP.gridRegionDirections="X|Y"213 newGRP.regionBounds.lower = (x-radius,y-radius,0)214 newGRP.regionBounds.upper = (x+radius,y+radius,0)215 return newGRP216 def _partGridParameters(self,targetCellSize):217 targetCellSize = empro.core.Expression(targetCellSize)218 newGP = empro.libpyempro.mesh.PartGridParameters()219 newGP.cellSizes.target = (targetCellSize,targetCellSize,0)220 newGP.gridRegionDirections="X|Y"221 newGP.useGridRegions = True222 return newGP223 def _create_sketch(self,pointString,sketch=None,closed=True):224 if getSessionVersion(self.session) >= 4:225 return self.session.create_sketch(pointString,sketch,closed)226 V=empro.geometry.Vector3d227 L=empro.geometry.Line228 def stringToPoint(s):229 sList = s.split('#')230 return V(sList[0],sList[1],0)231 if sketch == None:232 sketch=empro.geometry.Sketch()233 pointList = [ stringToPoint(x) for x in pointString.split(';') ]234 if closed:235 edges = [ L(pointList[i-1],pointList[i]) for i in range(len(pointList)) ]236 else:237 edges = [ L(pointList[2*i],pointList[2*i+1]) for i in range(len(pointList)/2) ]238 sketch.addEdges(edges)239 return sketch240 def _create_extrude(self, pointStrings, height, up):241 if getSessionVersion(self.session) >= 14:242 return self.session.create_extrude(pointStrings, height, up)243 else:244 sketch = None245 for pointString in pointStrings:246 sketch = self._create_sketch(pointString, sketch)247 part = empro.geometry.Model()248 part.recipe.append(empro.geometry.Extrude(sketch, height, empro.geometry.Vector3d(0, 0, (-1, 1)[up])))249 return part250 def _create_cover(self, pointStrings):251 if getSessionVersion(self.session) >= 14:252 return self.session.create_cover(pointStrings)253 else:254 sketch = None255 for pointString in pointStrings:256 sketch = self._create_sketch(pointString, sketch)257 part = empro.geometry.Model()258 part.recipe.append(empro.geometry.Cover(sketch))259 return part260 def _create_bondwire(self,radius, segments, points, name=None,bwAssembly=None,topAssembly=None,material=None,partModifier=(lambda x : x),profile=None,above=True):261 if getSessionVersion(self.session) >= 13:262 part = self.session.create_bondwire(radius, segments, points, name, bwAssembly,topAssembly,material,partModifier,profile,above)263 else:264 if profile is not None:265 part = empro.geometry.Model()266 try:267 part.recipe.append(empro.geometry.Bondwire(points[0],points[-1],profile))268 except TypeError:269 # Only for compatibility with EMPro 2011.02 or older270 self.session.warnings.append('For importing bondwires with profile definitions it is advised to use EMPro 2012.09 or later.')271 bw=empro.geometry.Bondwire(points[0],points[-1],empro.geometry.BondwireDefinition(name,radius,segments))272 bw.definition=profile273 part.recipe.append(bw)274 if not above:275 import math276 part.coordinateSystem.rotate(math.pi,0,0)277 part = partModifier(part)278 bwAssembly.append(part)279 part.name = name280 empro.toolkit.applyMaterial(part,material)281 else:282 try:283 part = self.session.create_bondwire(radius, segments, points, name, bwAssembly,topAssembly,material,partModifier)284 except TypeError:285 part = self.session.create_bondwire(radius, segments, points)286 part = partModifier(part)287 bwAssembly.append(part)288 part.name = name289 empro.toolkit.applyMaterial(part,material)290 part.meshParameters=empro.mesh.ModelMeshParameters()291 part.meshParameters.priority=2000292 return part293 def _create_internal_port(self, name, definitionString, head, tail, extent=None):294 if getSessionVersion(self.session) < 15 and (isinstance(head, list) or isinstance(tail, list)):295 raise RuntimeError("Ports having multiple positive or negative pins are not yet supported")296 if getSessionVersion(self.session) >= 9:297 return self.session.create_internal_port(name, definitionString, head, tail, extent)298 port=empro.components.CircuitComponent()299 port.name=name300 port.definition=self.circuitComponentDefinitions[definitionString]301 port.head=head302 port.tail=tail303 if extent != None:304 port.extent=extent305 port.useExtent=True306 return port307 def _set_extra_port_info(self, port, termType, number, name, feedType, mode = -1):308 try:309 if get_ads_import_version() >= 17:310 self.session.set_extra_port_info(port=port, termType=termType, number=number, name=name, mode=mode, feedType=feedType)311 else:312 self.session.set_extra_port_info(port=port, termType=termType, number=number, name=name, mode=mode)313 except AttributeError:314 pass315 global g_portNbToName316 g_portNbToName[number] = (name, mode)317 def _setAssemblyMeshSettings(self,a,vertexMeshLength=0,edgeMeshLength=0,surfaceMeshLength=0):318 if vertexMeshLength==0 and edgeMeshLength==0 and surfaceMeshLength==0:319 return320 if getSessionVersion(self.session) >= 12:321 self.session.setAssemblyMeshSettings(a,vertexMeshLength,edgeMeshLength,surfaceMeshLength)322 return323 parts = [x for x in a.flatList(False)]324 for x in parts:325 x.meshParameters.vertexMeshLength=vertexMeshLength326 x.meshParameters.edgeMeshLength=edgeMeshLength327 x.meshParameters.surfaceMeshLength=surfaceMeshLength328 def _getEMProMaterialName(self,ADSmaterialName,ADSmaterialMap,extraMaterialProperties,ADSmaterialsNo1to1):329 EMProMaterialName=ADSmaterialName330 if ADSmaterialName in [x for (x,y) in ADSmaterialMap.keys()]:331 EMProMaterialName+="_"+str(extraMaterialProperties)332 if not ADSmaterialName in ADSmaterialsNo1to1:333 ADSmaterialsNo1to1.append(ADSmaterialName)334 self.session.warnings.append('The ADS material '+ADSmaterialName+' is used on masks with different precedence, sheet thickness or modeltype for metals and has therefore been mapped to multiple EMPro materials.')335 return EMProMaterialName336 def create_bondwire_definitions(self):337 self.bondwire_definitions={}338 if not hasattr(empro.activeProject,"bondwireDefinitions"):339 return340 def create_materials(self,materialForEachLayer=False):341 ADSmaterialMap={}342 EMProNameMaterialMap={}343 layerEMProMaterialNameMap={}344 ADSmaterialsNo1to1=[]345 ADSmaterialName=["AIR","simulation_box"][materialForEachLayer]346 extraMaterialProperties=(0,None,None,False) # (priority,thickness,modelTypeForMetals,convertedToResistance)347 material=ADSmaterialMap.get((ADSmaterialName,extraMaterialProperties),None)348 if material == None:349 EMProMaterialName = self._getEMProMaterialName(ADSmaterialName,ADSmaterialMap,extraMaterialProperties,ADSmaterialsNo1to1)350 material=self.session.create_material(name=EMProMaterialName, color=(255,255,255,0), permittivity=1, permeability=1)351 try:352 material.priority=0353 material.autoPriority=False354 except AttributeError:355 pass356 ADSmaterialMap[(ADSmaterialName,extraMaterialProperties)]=material357 EMProNameMaterialMap[EMProMaterialName]=material358 else:359 EMProMaterialName=material.name360 self.materials["simulation_box"]=material361 layerEMProMaterialNameMap["simulation_box"]=EMProMaterialName362 ADSmaterialName=["Copper","cond"][materialForEachLayer]363 extraMaterialProperties=(162,4.5e-05,False,False) # (priority,thickness,modelTypeForMetals,convertedToResistance)364 material=ADSmaterialMap.get((ADSmaterialName,extraMaterialProperties),None)365 if material == None:366 EMProMaterialName = self._getEMProMaterialName(ADSmaterialName,ADSmaterialMap,extraMaterialProperties,ADSmaterialsNo1to1)367 material=self.session.create_material(name=EMProMaterialName, color=(255,0,0,255), conductivity=58000000, imag_conductivity=0, permeability=1)368 self._setModelTypeForMetals(material,False)369 try:370 material.priority=162371 material.autoPriority=False372 except AttributeError:373 pass374 ADSmaterialMap[(ADSmaterialName,extraMaterialProperties)]=material375 EMProNameMaterialMap[EMProMaterialName]=material376 else:377 EMProMaterialName=material.name378 self.materials["cond"]=material379 layerEMProMaterialNameMap["cond"]=EMProMaterialName380 ADSmaterialName=["PERFECT_CONDUCTOR","closed_bottom"][materialForEachLayer]381 extraMaterialProperties=(140,None,None,False) # (priority,thickness,modelTypeForMetals,convertedToResistance)382 material=ADSmaterialMap.get((ADSmaterialName,extraMaterialProperties),None)383 if material == None:384 EMProMaterialName = self._getEMProMaterialName(ADSmaterialName,ADSmaterialMap,extraMaterialProperties,ADSmaterialsNo1to1)385 material=self.session.create_material(name=EMProMaterialName, color=(192,192,192,255), resistance=0)386 try:387 material.priority=140388 material.autoPriority=False389 except AttributeError:390 pass391 ADSmaterialMap[(ADSmaterialName,extraMaterialProperties)]=material392 EMProNameMaterialMap[EMProMaterialName]=material393 else:394 EMProMaterialName=material.name395 self.materials["closed_bottom"]=material396 layerEMProMaterialNameMap["closed_bottom"]=EMProMaterialName397 ADSmaterialName=["FR4_RF","__SubstrateLayer1"][materialForEachLayer]398 extraMaterialProperties=(50,None,None,False) # (priority,thickness,modelTypeForMetals,convertedToResistance)399 material=ADSmaterialMap.get((ADSmaterialName,extraMaterialProperties),None)400 if material == None:401 EMProMaterialName = self._getEMProMaterialName(ADSmaterialName,ADSmaterialMap,extraMaterialProperties,ADSmaterialsNo1to1)402 material=self.session.create_material(name=EMProMaterialName, color=(202,225,255,128), permittivity=4.15, losstangent=0.015, permeability=1, use_djordjevic=True, lowfreq=1000, evalfreq=1000000000, highfreq=1000000000000)403 try:404 material.priority=50405 material.autoPriority=False406 except AttributeError:407 pass408 ADSmaterialMap[(ADSmaterialName,extraMaterialProperties)]=material409 EMProNameMaterialMap[EMProMaterialName]=material410 else:411 EMProMaterialName=material.name412 self.materials["__SubstrateLayer1"]=material413 layerEMProMaterialNameMap["__SubstrateLayer1"]=EMProMaterialName414 self.substratePartNameMap["__SubstrateLayer1"]=ADSmaterialName415 self.substrateLayers.append("__SubstrateLayer1")416 self.numberSubstratePartNameMap()417 if getSessionVersion(self.session) >= 6:418 self.session.appendUniqueMaterials(EMProNameMaterialMap)419 else:420 for name,material in EMProNameMaterialMap.items():421 empro.activeProject.materials().append(material)422 EMProNameMaterialMap[name] = empro.activeProject.materials().at(empro.activeProject.materials().size()-1)423 self.materials={}424 for layerName in layerEMProMaterialNameMap.keys():425 self.materials[layerName]=EMProNameMaterialMap.get(layerEMProMaterialNameMap.get(layerName,None),None)426 # End of create_materials427 def numberSubstratePartNameMap(self):428 materialCount={}429 for m in self.substratePartNameMap.keys():430 materialCount[self.substratePartNameMap[m]] = materialCount.get(self.substratePartNameMap[m],0) + 1431 multipleUsedMaterials = [m for m in materialCount.keys() if materialCount[m] > 1]432 for layer in self.substrateLayers:433 mat=self.substratePartNameMap.get(layer,None)434 if mat in multipleUsedMaterials:435 self.substratePartNameMap[layer]+=' '+str(materialCount[mat])436 materialCount[mat]-=1437 def setBoundaryConditions(self):438 empro.activeProject.boundaryConditions.zLowerBoundaryType="PEC"439 pass440 # End of setBoundaryConditions441 def setPortWarnings(self,includeInvalidPorts):442 pass443 # End of setPortWarnings444 def initNetlists(self):445 netlistNames = ['net_0','net_1_P1_P2','net_2']446 if getSessionVersion(self.session) >= 5:447 self.session.initNetlists(netlistNames)448 return449 self.groupList = []450 try:451 for i in netlistNames:452 g = empro.core.ShortcutGroup(i)453 self.groupList.append(g)454 except:455 pass456 def addShortcut(self,netId,part):457 if getSessionVersion(self.session) >= 5:458 self.session.addShortcut(netId,part)459 return460 try:461 s = empro.core.Shortcut(part)462 self.groupList[netId].append(s)463 except:464 pass465 def addShortcutsToProject(self):466 if getSessionVersion(self.session) >= 5:467 self.session.addShortcutsToProject()468 return469 try:470 for g in self.groupList:471 empro.activeProject.shortcuts().append(g)472 except:473 pass474 def ads_import(self,usedFlow="ADS",topAssembly=None,demoMode=False,includeInvalidPorts=True,suppressNotification=False,materialForEachLayer=False):475 if getSessionVersion(self.session) >= 1:476 self.session.prepare_import()477 self.create_materials(materialForEachLayer=materialForEachLayer)478 self.create_parameters()479 if topAssembly != None:480 topAssemblyShouldBeAdded = False481 else:482 topAssembly = empro.geometry.Assembly()483 topAssembly.name = usedFlow+'_import'484 if demoMode:485 empro.activeProject.geometry.append(topAssembly)486 topAssemblyShouldBeAdded = False487 else:488 topAssemblyShouldBeAdded = True489 param_list = empro.activeProject.parameters490 param_list.setFormula( "lateralExtension", "0 mm")491 param_list.setFormula( "verticalExtension", "0 mm")492 self.create_bondwire_definitions()493 self.setBoundaryConditions()494 symbPinData = self.create_geometry(topAssembly)495 self.create_ports( topAssembly, includeInvalidPorts, symbPinData )496 if get_ads_import_version() >= 11 :497 Expr=empro.core.Expression498 if topAssembly != None:499 bbox_geom = topAssembly.boundingBox()500 else:501 bbox_geom = empro.activeProject.geometry.boundingBox()502 param_list = empro.activeProject.parameters503 param_list.setFormula( "xLowerBoundingBox", str(bbox_geom.lower.x.formula()) +" m - xLowerExtension" )504 param_list.setFormula( "xUpperBoundingBox", str(bbox_geom.upper.x.formula()) +" m + xUpperExtension" )505 param_list.setFormula( "yLowerBoundingBox", str(bbox_geom.lower.y.formula()) +" m - yLowerExtension" )506 param_list.setFormula( "yUpperBoundingBox", str(bbox_geom.upper.y.formula()) +" m + yUpperExtension" )507 param_list.setFormula( "zLowerBoundingBox", str(bbox_geom.lower.z.formula()) +" m - zLowerExtension" )508 param_list.setFormula( "zUpperBoundingBox", str(bbox_geom.upper.z.formula()) +" m + zUpperExtension" )509 param_list.setFormula( "toggleExtensionToBoundingBox", "1" )510 param_list.setFormula( "lateralExtension", "3.125 mm")511 param_list.setFormula("verticalExtension", "5 mm")512 self.addShortcutsToProject()513 if topAssemblyShouldBeAdded:514 empro.activeProject.geometry.append(topAssembly)515 self.session.adjust_view()516 self.session.renumber_waveguides()517 if getSessionVersion(self.session) >= 10:518 self.session.post_import()519 if not suppressNotification:520 self.session.notify_success()521 return self.session.warnings522 #End of ads_import method523 def create_geometry(self,topAssembly):524 V=empro.geometry.Vector3d525 L=empro.geometry.Line526 unit2meterFactor = 0.001527 symbPinData = None528 mask_heights=self.getMaskHeights()529 mask_heights_parameterized=self.getMaskHeightsParameterized()530 s3dc_files={}531 s3dc_files["libS3D.xml"]="eJyzCTZ2cbbjstGH0AAcBANS"532 if hasattr(self.session, "create_3d_components"):533 if get_ads_import_version() >= 11 :534 symbPinData = self.session.create_3d_components(s3dc_files, mask_heights, topAssembly, unit2meterFactor)535 else:536 try:537 self.session.create_3d_components(s3dc_files, mask_heights,topAssembly)538 except TypeError:539 self.session.create_3d_components(s3dc_files, mask_heights)540 assembly=empro.geometry.Assembly()541 assembly.name="bondwires"542 assembly=empro.geometry.Assembly()543 part=empro.geometry.Model()544 simBox = empro.geometry.Box( _createIfToggleExtensionToBoundingBoxExpression("xUpperBoundingBox-xLowerBoundingBox", "abs((0-xLowerExtension)-(0.014+xUpperExtension))"), _createIfToggleExtensionToBoundingBoxExpression("zUpperBoundingBox-zLowerBoundingBox", "((((stack_tech_layer_5_Z) + (zUpperExtension)) - (stack_tech_layer_1_Z)))"), _createIfToggleExtensionToBoundingBoxExpression("yUpperBoundingBox-yLowerBoundingBox" , " abs((-0.0005-yLowerExtension)-(0.0133034+yUpperExtension))"))545 part.recipe.append(simBox)546 part.coordinateSystem.anchorPoint = empro.geometry.CoordinateSystemPositionExpression(V(_createIfToggleExtensionToBoundingBoxExpression("(xUpperBoundingBox+xLowerBoundingBox)/2", "(0.014+xUpperExtension+0-xLowerExtension)/2"), _createIfToggleExtensionToBoundingBoxExpression("(yUpperBoundingBox+yLowerBoundingBox)/2", "(0.0133034+yUpperExtension+-0.0005-yLowerExtension)/2"), _createIfToggleExtensionToBoundingBoxExpression("zLowerBoundingBox","((stack_tech_layer_1_Z) - (0))")))547 part.name="Simulation box"548 part.meshParameters=empro.mesh.ModelMeshParameters()549 part.meshParameters.priority=0550 empro.toolkit.applyMaterial(part,self.materials["simulation_box"])551 assembly.append(part)552 assembly.name="simulation_box"553 self.session.hide_part(assembly)554 topAssembly.append(assembly)555 self.session.adjust_view()556 assembly=empro.geometry.Assembly()557 pointString='0.014+xUpperExtension#-0.0005-yLowerExtension;0.014+xUpperExtension#0.0133034+yUpperExtension;0-xLowerExtension#0.0133034+yUpperExtension;0-xLowerExtension#-0.0005-yLowerExtension'558 sketch = self._create_sketch(pointString)559 sketch.constraintManager().append(empro.geometry.FixedPositionConstraint("vertex0",V(_createIfToggleExtensionToBoundingBoxExpression("xLowerBoundingBox","0-xLowerExtension"),_createIfToggleExtensionToBoundingBoxExpression("yLowerBoundingBox","-0.0005-yLowerExtension"),0)))560 sketch.constraintManager().append(empro.geometry.FixedPositionConstraint("vertex1",V(_createIfToggleExtensionToBoundingBoxExpression("xUpperBoundingBox","0.014+xUpperExtension"),_createIfToggleExtensionToBoundingBoxExpression("yLowerBoundingBox","-0.0005-yLowerExtension"),0)))561 sketch.constraintManager().append(empro.geometry.FixedPositionConstraint("vertex2",V(_createIfToggleExtensionToBoundingBoxExpression("xUpperBoundingBox","0.014+xUpperExtension"),_createIfToggleExtensionToBoundingBoxExpression("yUpperBoundingBox","0.0133034+yUpperExtension"),0)))562 sketch.constraintManager().append(empro.geometry.FixedPositionConstraint("vertex3",V(_createIfToggleExtensionToBoundingBoxExpression("xLowerBoundingBox","0-xLowerExtension"),_createIfToggleExtensionToBoundingBoxExpression("yUpperBoundingBox","0.0133034+yUpperExtension"),0)))563 part=empro.geometry.Model()564 part.recipe.append(empro.geometry.Extrude(sketch,"(stack_tech_layer_3_Z) - (stack_tech_layer_1_Z)",V(0,0,1)))565 part.coordinateSystem.anchorPoint = empro.geometry.CoordinateSystemPositionExpression(V(0,0,"(stack_tech_layer_1_Z) - (0)"))566 part.name=self.substratePartNameMap["__SubstrateLayer1"]567 part.meshParameters=empro.mesh.ModelMeshParameters()568 part.meshParameters.priority=50569 empro.toolkit.applyMaterial(part,self.materials["__SubstrateLayer1"])570 self.session.hide_part(part)571 assembly.append(part)572 assembly.name="substrate"573 topAssembly.append(assembly)574 assembly=empro.geometry.Assembly()575 pointStrings=['0.014#-0.0005;0.014#0.0005;0#0.0005;0#-0.0005']576 part = self._create_extrude(pointStrings, "(mask_cond_Zmax) - (mask_cond_Zmin)", up=True)577 part.coordinateSystem.anchorPoint = empro.geometry.CoordinateSystemPositionExpression(V(0,0,"(mask_cond_Zmin) - (0)"))578 part.setAttribute('LtdLayerNumber', 2)579 part.meshParameters=empro.mesh.ModelMeshParameters()580 part.meshParameters.priority=162581 empro.toolkit.applyMaterial(part,self.materials["cond"])582 assembly.append(part)583 self.addShortcut(1,part)584 self._update_geoProgress()585 pointStrings=['0.0091517#0.0086517;0.0091517#0.0123034;0.0093034#0.0123034;0.0093034#0.0133034;0.0081517#0.0121517;0.0081517#0.0085;0.008#0.0085;0.008#0.0075']586 part = self._create_extrude(pointStrings, "(mask_cond_Zmax) - (mask_cond_Zmin)", up=True)587 part.coordinateSystem.anchorPoint = empro.geometry.CoordinateSystemPositionExpression(V(0,0,"(mask_cond_Zmin) - (0)"))588 part.setAttribute('LtdLayerNumber', 2)589 part.meshParameters=empro.mesh.ModelMeshParameters()590 part.meshParameters.priority=162591 empro.toolkit.applyMaterial(part,self.materials["cond"])592 assembly.append(part)593 self.addShortcut(0,part)594 self._setAssemblyMeshSettings(assembly,0,0,0)595 assembly.name="cond"596 topAssembly.append(assembly)597 assembly=empro.geometry.Assembly()598 pointStrings=['0.017125#-0.003625;0.017125#0.0164284;-0.003125#0.0164284;-0.003125#-0.003625']599 sketch = None600 for pointString in pointStrings:601 sketch = self._create_sketch(pointString, sketch)602 sketch.constraintManager().append(empro.geometry.FixedPositionConstraint("vertex0",V(_createIfToggleExtensionToBoundingBoxExpression("xLowerBoundingBox","0-xLowerExtension"),_createIfToggleExtensionToBoundingBoxExpression("yLowerBoundingBox","-0.0005-yLowerExtension"),0)))603 sketch.constraintManager().append(empro.geometry.FixedPositionConstraint("vertex1",V(_createIfToggleExtensionToBoundingBoxExpression("xUpperBoundingBox","0.014+xUpperExtension"),_createIfToggleExtensionToBoundingBoxExpression("yLowerBoundingBox","-0.0005-yLowerExtension"),0)))604 sketch.constraintManager().append(empro.geometry.FixedPositionConstraint("vertex2",V(_createIfToggleExtensionToBoundingBoxExpression("xUpperBoundingBox","0.014+xUpperExtension"),_createIfToggleExtensionToBoundingBoxExpression("yUpperBoundingBox","0.0133034+yUpperExtension"),0)))605 sketch.constraintManager().append(empro.geometry.FixedPositionConstraint("vertex3",V(_createIfToggleExtensionToBoundingBoxExpression("xLowerBoundingBox","0-xLowerExtension"),_createIfToggleExtensionToBoundingBoxExpression("yUpperBoundingBox","0.0133034+yUpperExtension"),0)))606 part=empro.geometry.Model()607 part.recipe.append(empro.geometry.Cover(sketch))608 part.coordinateSystem.anchorPoint = empro.geometry.CoordinateSystemPositionExpression(V(0,0,"(stack_tech_layer_1_Z) - (0)"))609 part.meshParameters=empro.mesh.ModelMeshParameters()610 try:611 mtrl = self.materials["closed_bottom"]612 if mtrl.details.materialType() == "Physical": 613 eProp = mtrl.details.electricProperties614 if eProp.propertyType() == "PEC" or eProp.parameters.parametersType() == "PEC":615 if topAssembly != None:616 bbox_3dcs = topAssembly.boundingBox()617 else:618 bbox_3dcs = empro.activeProject.geometry.boundingBox()619 SPAresabs=empro.activeProject.newPartModelingUnit.toReferenceUnits(1e-6)620 if (float(empro.core.Expression("((stack_tech_layer_1_Z) - (0))")) <= bbox_3dcs.lower.z + SPAresabs ) :621 part.meshParameters.includeInMesh=False622 empro.activeProject.parameters.setFormula( "zLowerExtension", "0 mm")623 except AttributeError:624 part.meshParameters.includeInMesh=False625 part.meshParameters.priority=140626 empro.toolkit.applyMaterial(part,self.materials["closed_bottom"])627 assembly.append(part)628 self.addShortcut(2,part)629 self._setAssemblyMeshSettings(assembly,0,0,0)630 assembly.name="closed_bottom"631 topAssembly.append(assembly)632 return symbPinData633 # End of create_geometry634 def _update_geoProgress(self):635 self.geoProgress+= 1636 if self.geoProgress % 1 == 0:637 progress = (self.geoProgress * 100)/1638 self._updateProgress(progress)639 def getMaskHeights(self,parameterized=False):640 mask_heights={}641 mask_heights_parameterized={}642 mask_heights[2]=(0.0005, 0.000545)643 mask_heights_parameterized[2]=("(mask_cond_Zmin) - (0)", "(mask_cond_Zmax) - (0)")644 if(parameterized):645 return mask_heights_parameterized646 else:647 return mask_heights648 def getMaskHeightsParameterized(self):649 return self.getMaskHeights(parameterized=True)650 def create_ports( self, topAssembly, includeInvalidPorts=True, symbPinData=None):651 self.setPortWarnings(includeInvalidPorts)652 V=empro.geometry.Vector3d653 L=empro.geometry.Line654 SPAresabs=empro.activeProject.newPartModelingUnit.toReferenceUnits(1e-6)655 if topAssembly != None:656 bbox_geom = topAssembly.boundingBox()657 else:658 bbox_geom = empro.activeProject.geometry.boundingBox()659 xLowerBoundary = float(bbox_geom.lower.x)660 xUpperBoundary = float(bbox_geom.upper.x)661 yLowerBoundary = float(bbox_geom.lower.y)662 yUpperBoundary = float(bbox_geom.upper.y)663 zLowerBoundary = float(bbox_geom.lower.z)664 zUpperBoundary = float(bbox_geom.upper.z)665 internalPortOnXLowerBoundary = False666 internalPortOnXUpperBoundary = False667 internalPortOnYLowerBoundary = False668 internalPortOnYUpperBoundary = False669 internalPortOnZLowerBoundary = False670 internalPortOnZUpperBoundary = False671 ports=[]672 waveguides={}673 portShortcutGroups=[]674 assembly=empro.geometry.Assembly()675 waveform=empro.waveform.Waveform("Broadband Pulse")676 waveform.shape=empro.waveform.MaximumFrequencyWaveformShape()677 self.waveforms["Broadband Pulse"]=waveform678 if getSessionVersion(self.session) >= 7:679 self.session.appendUniqueWaveforms(self.waveforms)680 else:681 for name,waveform in self.waveforms.items():682 empro.activeProject.waveforms.append(waveform)683 self.waveforms[name] = empro.activeProject.waveforms[len(empro.activeProject.waveforms)-1]684 feed=empro.components.Feed()685 feed.name="50 ohm Voltage Source"686 feed.impedance.resistance=50687 feed.waveform=self.waveforms["Broadband Pulse"]688 self.circuitComponentDefinitions[feed.name]=feed689 if getSessionVersion(self.session) >= 7:690 self.session.appendUniqueCircuitComponentDefinitions(self.circuitComponentDefinitions)691 else:692 for name,compDef in self.circuitComponentDefinitions.items():693 empro.activeProject.circuitComponentDefinitions.append(compDef)694 self.circuitComponentDefinitions[name] = empro.activeProject.circuitComponentDefinitions[len(empro.activeProject.circuitComponentDefinitions)-1]695 head=V("(0) - (0)","(0) - (0)","(((mask_cond_Zmax) + (mask_cond_Zmin)) / (2)) - (0)")696 tail=V("(0) - (0)","(0) - (0)","(stack_tech_layer_1_Z) - (0)")697 extent=empro.components.SheetExtent()698 extent.endPoint1Position=V("(0) - (0)","(-0.0005) - (0)","(stack_tech_layer_1_Z) - (0)")699 extent.endPoint2Position=V("(0) - (0)","(0.0005) - (0)","(((mask_cond_Zmax) + (mask_cond_Zmin)) / (2)) - (0)")700 port = self._create_internal_port("P1","50 ohm Voltage Source",head,tail,extent)701 portShortcutGroups.append((1,port))702 ports.append(port)703 self._set_extra_port_info(port, "inputOutput", 1, "P1", "Direct")704 headsAndTails = (head if isinstance(head, list) else [head]) + (tail if isinstance(tail, list) else [tail])705 for headOrTail in headsAndTails:706 if abs(float(headOrTail.x) - xLowerBoundary) < SPAresabs: internalPortOnXLowerBoundary = True707 if abs(float(headOrTail.x) - xUpperBoundary) < SPAresabs: internalPortOnXUpperBoundary = True708 if abs(float(headOrTail.y) - yLowerBoundary) < SPAresabs: internalPortOnYLowerBoundary = True709 if abs(float(headOrTail.y) - yUpperBoundary) < SPAresabs: internalPortOnYUpperBoundary = True710 if abs(float(headOrTail.z) - zLowerBoundary) < SPAresabs: internalPortOnZLowerBoundary = True711 if abs(float(headOrTail.z) - zUpperBoundary) < SPAresabs: internalPortOnZUpperBoundary = True712 head=V("(0.014) - (0)","(0) - (0)","(((mask_cond_Zmax) + (mask_cond_Zmin)) / (2)) - (0)")713 tail=V("(0.014) - (0)","(0) - (0)","(stack_tech_layer_1_Z) - (0)")714 extent=empro.components.SheetExtent()715 extent.endPoint1Position=V("(0.014) - (0)","(-0.0005) - (0)","(stack_tech_layer_1_Z) - (0)")716 extent.endPoint2Position=V("(0.014) - (0)","(0.0005) - (0)","(((mask_cond_Zmax) + (mask_cond_Zmin)) / (2)) - (0)")717 port = self._create_internal_port("P2","50 ohm Voltage Source",head,tail,extent)718 portShortcutGroups.append((1,port))719 ports.append(port)720 self._set_extra_port_info(port, "inputOutput", 2, "P2", "Direct")721 headsAndTails = (head if isinstance(head, list) else [head]) + (tail if isinstance(tail, list) else [tail])722 for headOrTail in headsAndTails:723 if abs(float(headOrTail.x) - xLowerBoundary) < SPAresabs: internalPortOnXLowerBoundary = True724 if abs(float(headOrTail.x) - xUpperBoundary) < SPAresabs: internalPortOnXUpperBoundary = True725 if abs(float(headOrTail.y) - yLowerBoundary) < SPAresabs: internalPortOnYLowerBoundary = True726 if abs(float(headOrTail.y) - yUpperBoundary) < SPAresabs: internalPortOnYUpperBoundary = True727 if abs(float(headOrTail.z) - zLowerBoundary) < SPAresabs: internalPortOnZLowerBoundary = True728 if abs(float(headOrTail.z) - zUpperBoundary) < SPAresabs: internalPortOnZUpperBoundary = True729 setPortNbToNameMappingInitialized()730 try:731 if getSessionVersion(self.session) >= 5:732 self.session.appendPortList(ports,None,portShortcutGroups)733 else:734 self.session.appendPortList(ports,self.groupList,portShortcutGroups)735 except AttributeError:736 empro.activeProject.circuitComponents().appendList(ports)737 for group,port in portShortcutGroups:738 self.addShortcut(group,port)739 for i in waveguides.keys():740 empro.activeProject.waveGuides.append(waveguides[i])741 assembly.name="waveguide_planes"742 self.session.hide_part(assembly)743 def create_grid_regions(self):744 gG = empro.activeProject.gridGenerator745 def create_parameters(self):746 self._create_parameter("stack_tech_layer_1_Z", "0 mm", "Z of topology level (level 1 of stack tech)",True,fixGridAxis='Z')747 self._create_parameter("stack_tech_layer_3_Z", "0.5 mm", "Z of topology level (level 3 of stack tech)",True,fixGridAxis='Z')748 self._create_parameter("stack_tech_layer_5_Z", "0.545 mm", "Z of topology level (level 5 of stack tech)",True,fixGridAxis='Z')749 self._create_parameter("lateralExtension","3.125 mm","Substrate LATERAL extension", True)750 self._create_parameter("verticalExtension","5 mm","Substrate VERTICAL extension", True)751 self._create_parameter("xLowerExtension", "lateralExtension", "Lower X extension", True)752 self._create_parameter("xUpperExtension", "lateralExtension", "Upper X extension", True)753 self._create_parameter("yLowerExtension", "lateralExtension", "Lower Y extension", True)754 self._create_parameter("yUpperExtension", "lateralExtension", "Upper Y extension", True)755 self._create_parameter("zLowerExtension", "verticalExtension", "Lower Z extension", True)756 self._create_parameter("zUpperExtension", "verticalExtension", "Upper Z extension", True)757 if get_ads_import_version() >= 11 :758 self._create_parameter("toggleExtensionToBoundingBox", 0, "toggle extension of gnd/substrate layers to bounding box of geometry", True)759 self._create_parameter("xLowerBoundingBox", 0.0, "lower X coordinate of bounding box of geometry (for extension of covers)", True)760 self._create_parameter("yLowerBoundingBox", 0.0, "lower Y coordinate of bounding box of geometry (for extension of covers)", True)761 self._create_parameter("zLowerBoundingBox", 0.0, "lower Z coordinate of bounding box of geometry (for extension of covers)", True)762 self._create_parameter("xUpperBoundingBox", 0.0, "upper X coordinate of bounding box of geometry (for extension of covers)", True)763 self._create_parameter("yUpperBoundingBox", 0.0, "upper Y coordinate of bounding box of geometry (for extension of covers)", True)764 self._create_parameter("zUpperBoundingBox", 0.0, "upper Z coordinate of bounding box of geometry (for extension of covers)", True)765 self._create_parameter("mask_cond_Zmin",str("0.5 mm"),"Zmin of mask cond",True,fixGridAxis='Z')766 self._create_parameter("mask_cond_Zmax",str("0.545 mm"),"Zmax of mask cond",True,fixGridAxis='Z')767def maxNbThreadsADS():768 maxNbThreads=0769 return maxNbThreads770g_portNbToName={}771g_portNbToNameInitialized=False772def portNbToName():773 if g_portNbToNameInitialized == True:774 return g_portNbToName775 raise RuntimeError("portNbToName used uninitialized")776def setPortNbToNameMappingInitialized( state = True ):777 global g_portNbToNameInitialized778 g_portNbToNameInitialized = True779def radiationPossible():780 return True...
copasi.py
Source:copasi.py
...49 return result50 def _create_problem(self):51 result = etree.Element('Problem')52 result.extend([53 self._create_parameter('AutomaticStepSize', 'bool', 0),54 self._create_parameter('StepNumber', 'unsignedInteger', 100),55 self._create_parameter('StepSize', 'float', self._max_time/100),56 self._create_parameter('Duration', 'float', self._max_time),57 self._create_parameter('TimeSeriesRequested', 'bool', 1),58 self._create_parameter('OutputStartTime', 'float', 0),59 self._create_parameter('Output Event', 'bool', 0),60 self._create_parameter('Start in Steady State', 'bool', 0)61 ])62 return result63 def _create_parameter(self, name, type_, value):64 result = etree.Element('Parameter')65 result.set('name', name)66 result.set('type', type_)67 result.set('value', str(value))68 return result69 def _create_method(self):70 result = etree.Element('Method')71 result.set('name', 'Stochastic (Gibson + Bruck)')72 result.set('type', 'DirectMethod')73 #result.set('name', 'Stochastic (Direct method)')74 #result.set('type', 'Stochastic')75 result.extend([76 self._create_parameter('Max Internal Steps', 'integer', '1000000'),77 self._create_parameter('Subtype', 'unsignedInteger', '2'),78 self._create_parameter('Use Random Seed', 'bool', '1'),79 self._create_parameter('Random Seed', 'unsignedInteger', '1')80 ])81 return result82class CopasiReport(object):83 def __init__(self, cascade_size):84 self._xml = self._create_report()85 self._xml.extend([86 self._create_comment(),87 self._create_table(cascade_size)88 ])89 def _create_report(self):90 result = etree.Element('Report')91 result.set('key', 'Report_benchmark')92 result.set('name', 'Time, Particle Numbers, Volumes, '93 'and Global Quantity Values')...
model_test.py
Source:model_test.py
...23 def tearDown(self):24 # Restore previous log level25 logger = logging.getLogger('pando.model')26 logger.setLevel(self.logLevel)27 def _create_parameter(self, name, model):28 p = pando.model.Parameter(name=name, uid=name.lower(), description=None, parameter_type=None)29 model.parameters[p.uid] = p30 return p31 def _create_repeater(self, name, model):32 p = pando.model.Repeater(name=name, uid=name.lower(), description=None, parameter_type=None)33 model.parameters[p.uid] = p34 return p35 def _generate_packet(self, model):36 packet = pando.model.Packet(name="Test", uid="test", description="",37 packet_type=pando.model.Packet.TELECOMMAND)38 packet.append_parameter(self._create_parameter("P1", model))39 repeater = self._create_repeater("P2", model)40 repeater.append_parameter(self._create_parameter("P3", model))41 packet.append_parameter(repeater)42 packet.append_parameter(self._create_parameter("P4", model))43 model.telecommands[packet.uid] = packet44 return packet45 def _generate_packet_with_nested_repeaters(self, model):46 packet = pando.model.Packet(name="Test", uid="test", description="",47 packet_type=pando.model.Packet.TELECOMMAND)48 packet.append_parameter(self._create_parameter("P1", model))49 repeater = self._create_repeater("G1", model)50 repeater.append_parameter(self._create_parameter("P2", model))51 repeater2 = self._create_repeater("G2", model)52 repeater2.append_parameter(self._create_parameter("P3", model))53 repeater2.append_parameter(self._create_parameter("P4", model))54 repeater.append_parameter(repeater2)55 packet.append_parameter(repeater)56 packet.append_parameter(self._create_parameter("P5", model))57 model.telecommands[packet.uid] = packet58 return packet59 def test_should_flatten_parameters(self):60 m = pando.model.Model()61 packet = self._generate_packet(m)62 parameters = packet.get_parameters_as_flattened_list()63 self.assertIsNotNone(parameters)64 self.assertEqual(len(parameters), 4)65 self.assertEqual(parameters[0].uid, "p1")66 self.assertEqual(parameters[1].uid, "p2")67 self.assertEqual(parameters[2].uid, "p3")68 self.assertEqual(parameters[3].uid, "p4")69 def test_should_have_correct_repeater_member_count(self):70 model = pando.model.Model()...
Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.
You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.
Get 100 minutes of automation test minutes FREE!!