How to use relCoords method in fMBT

Best Python code snippet using fMBT_python

drawDiodes.py

Source:drawDiodes.py Github

copy

Full Screen

...26 group = self.createGroup(parent, label)27 elem = self.createGroup(group)28 if mirror:29 if flagType == 'varicap':30 inkDraw.line.relCoords(elem, [[-(16 + wireExtraSize), 0]], self.add(position, [-9, 0]))31 else:32 inkDraw.line.relCoords(elem, [[-(19 + wireExtraSize), 0]], self.add(position, [-6, 0]))33 inkDraw.line.relCoords(elem, [[12, 6], [0, -12], [-12, 6]], self.add(position, [-6, 0]))34 inkDraw.line.relCoords(elem, [[19 + wireExtraSize, 0]], self.add(position, [6, 0]))35 if flagType in ['regular', 'LED', 'photoDiode']:36 inkDraw.line.relCoords(elem, [[0, 12]], self.add(position, [-6, -6]))37 if flagType == 'zener':38 inkDraw.line.relCoords(elem, [[-2, -2], [0, -10], [-2, -2]], self.add(position, [-6 + 2, 5 + 2]))39 if flagType == 'schottky':40 inkDraw.line.relCoords(elem, [[0, 2], [3, 0], [0, -12], [3, 0], [0, 2]], self.add(position, [-6 - 3, 6 - 2]))41 if flagType == 'tunnel':42 inkDraw.line.relCoords(elem, [[-3, 0], [0, -12], [3, 0]], self.add(position, [-6 + 3, 6]))43 if flagType == 'varicap':44 inkDraw.line.relCoords(elem, [[0, 12]], self.add(position, [-6, -6]))45 inkDraw.line.relCoords(elem, [[0, 12]], self.add(position, [-9, -6]))46 else:47 if flagType == 'varicap':48 inkDraw.line.relCoords(elem, [[16 + wireExtraSize, 0]], self.add(position, [6 + 3, 0]))49 else:50 inkDraw.line.relCoords(elem, [[19 + wireExtraSize, 0]], self.add(position, [6, 0]))51 inkDraw.line.relCoords(elem, [[-(19 + wireExtraSize), 0]], self.add(position, [-6, 0]))52 inkDraw.line.relCoords(elem, [[-12, 6], [0, -12], [12, 6]], self.add(position, [6, 0]))53 if flagType in ['regular', 'LED', 'photoDiode']:54 inkDraw.line.relCoords(elem, [[0, 12]], self.add(position, [6, -6]))55 if flagType == 'zener':56 inkDraw.line.relCoords(elem, [[-2, -2], [0, -10], [-2, -2]], self.add(position, [6 + 2, 5 + 2]))57 if flagType == 'schottky':58 inkDraw.line.relCoords(elem, [[0, 2], [3, 0], [0, -12], [3, 0], [0, 2]], self.add(position, [6 - 3, 6 - 2]))59 if flagType == 'tunnel':60 inkDraw.line.relCoords(elem, [[3, 0], [0, -12], [-3, 0]], self.add(position, [6 - 3, 6]))61 if flagType == 'varicap':62 inkDraw.line.relCoords(elem, [[0, 12]], self.add(position, [6, -6]))63 inkDraw.line.relCoords(elem, [[0, 12]], self.add(position, [9, -6]))64 if value is not None:65 if flagType == 'LED':66 pos_text = self.add(position, [0, -13 - self.textOffset])67 if flagType == 'photoDiode':68 pos_text = self.add(position, [0, -13 - self.textOffset])69 if flagType in ['regular', 'zener', 'schottky', 'tunnel', 'varicap']:70 pos_text = self.add(position, [0, -6 - self.textOffset])71 if inkDraw.useLatex:72 value = '$' + value + '$'73 inkDraw.text.latex(self, group, value, pos_text, fontSize=self.fontSize, refPoint='bc', preambleFile=self.preambleFile)74 if angleDeg != 0:75 self.rotateElement(group, position, angleDeg)76 if flagVolt:77 if convention == 'passive':78 self.drawVoltArrow(group, self.add(position, [0, 7]), name=voltName, color=self.voltageColor, angleDeg=angleDeg,79 invertArrows=not (invertArrows != mirror))80 if convention == 'active':81 self.drawVoltArrow(group, self.add(position, [0, 7]), name=voltName, color=self.voltageColor, angleDeg=angleDeg,82 invertArrows=(invertArrows != mirror))83 if flagCurr:84 self.drawCurrArrow(group, self.add(position, [20 + wireExtraSize, -5]), name=currName, color=self.currentColor, angleDeg=angleDeg,85 invertArrows=(invertArrows != mirror))86 if flagType == 'LED':87 arrow = self.createGroup(elem)88 inkDraw.line.relCoords(arrow, [[7, 0]], position)89 inkDraw.line.relCoords(arrow, [[1.5, -1.5], [-1.5, -1.5]], self.add(position, [5.5, 1.5]))90 self.rotateElement(arrow, position, 60)91 self.moveElement(arrow, [-3, -8])92 self.copyElement(arrow, elem, distance=[5, 2])93 if flagType == 'photoDiode':94 arrow = self.createGroup(elem)95 inkDraw.line.relCoords(arrow, [[7, 0]], position)96 inkDraw.line.relCoords(arrow, [[1.5, -1.5], [-1.5, -1.5]], self.add(position, [5.5, 1.5]))97 self.rotateElement(arrow, position, -120)98 self.moveElement(arrow, [0, -14])99 self.copyElement(arrow, elem, distance=[5, 2])...

Full Screen

Full Screen

geometry.py

Source:geometry.py Github

copy

Full Screen

1#------------------------------------------------------------------------------#2# DFTB+: general package for performing fast atomistic simulations #3# Copyright (C) 2017 DFTB+ developers group #4# #5# See the LICENSE file for terms of usage and distribution. #6#------------------------------------------------------------------------------#7#8'''Representation of a geometry'''9import numpy as np10import numpy.linalg as la11__all__ = ["Geometry"]12class Geometry:13 """Atomic geometry representation.14 Attributes:15 specienames: Name of atomtypes which can be found in the geometry.16 nspecie: Number of species.17 indexes: For each atom the index of the corresponding specie18 in specienames.19 natom: Number of atoms.20 coords: xyz coordinates of the atoms.21 origin: Origin.22 periodic: True if the structure is periodic.23 latvecs: Lattice vectors (None for non-periodic structures).24 relcoords: Relative lattice coordinates (None if non-periodic).25 """26 def __init__(self, specienames, indexes, coords, latvecs=None, origin=None,27 relcoords=False):28 """Initializes a geometry object.29 Args:30 specienames: Names of the species occuring in the geometry.31 indexes: Species index for every atom. Shape (natom,)32 coords: Coordinates of the atoms.33 latvecs: Lattice vectors (default: None, non-periodic modell).34 origin: Origin of the primitive cell (default (0.0, 0.0, 0.0))35 relcoords: If set to yes, coordinates are assumed to be relative36 coordinates specified as multiples of the lattice vectors.37 """38 self.specienames = list(specienames)39 self.nspecie = len(self.specienames)40 self.indexes = np.array(indexes)41 self.natom = len(self.indexes)42 self.coords = np.array(coords)43 if origin is None:44 self.origin = np.array((0, 0, 0), dtype=float)45 else:46 self.origin = np.array(origin, dtype=float)47 self.periodic = latvecs is not None48 if self.periodic:49 self.latvecs = np.array(latvecs, dtype=float)50 self._invlatvecs = la.inv(self.latvecs)51 if relcoords:52 self.relcoords = coords53 self.coords = np.dot(self.relcoords, self.latvecs) + self.origin54 else:55 self.coords = coords56 self.relcoords = np.dot(self.coords - self.origin,57 self._invlatvecs)58 else:59 self.latvecs = None60 self._invlatvecs = None61 self.relcoords = None62 def setlattice(self, latvecs, origin=None):63 """Makes geometry periodic or changes supercell vectors.64 Args:65 latvecs: Periodicity defined by lattice vectors.66 origin: Origin (default: 0, 0, 0)67 """68 self.latvecs = np.array(latvecs, dtype=float)69 self._invlatvecs = la.inv(self.latvecs)70 if origin is None:71 self.origin = np.array((0, 0, 0), dtype=float)72 else:73 self.origin = np.array(origin, dtype=float)74 self.relcoords = np.dot(self.coords - self.origin, self._invlatvecs)75 self.periodic = True76 def equals(self, other, tolerance):77 '''Checks whether object equals to an other one.78 Args:79 other (Geometry): Other geometry.80 tolerance (float): Maximal allowed deviation in floating point81 numbers (e.g. coordinates).82 '''83 if self.specienames != other.specienames:84 return False85 if np.any(self.indexes != other.indexes):86 return False87 if np.any(abs(self.coords - other.coords) > tolerance):88 return False89 if np.any(abs(self.origin - other.origin) > tolerance):90 return False91 if self.periodic != other.periodic:92 return False93 if self.periodic:94 if np.any(abs(self.latvecs - other.latvecs) > tolerance):95 return False96 if np.any(abs(self.relcoords - other.relcoords) > tolerance):97 return False...

Full Screen

Full Screen

Automation Testing Tutorials

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.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run fMBT automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful