Ejemplo n.º 1
0
def add_number(m, key, table, column, row):
    try:
        v = table.get_value(column, row)
        if v in ('', '?', '.'):
            return False
        m[key] = CIF.makeNumber(v)
        return True
    except (IndexError, KeyError, ValueError):
        return False
Ejemplo n.º 2
0
def add_number(m, key, table, column, row):
    try:
        v = table.get_value(column, row)
        if v in ('', '?', '.'):
            return False
        m[key] = CIF.makeNumber(v)
        return True
    except (IndexError, KeyError, ValueError):
        return False
Ejemplo n.º 3
0
 def read_start(self, filobj):
     ## parse the CIF file
     cif_file = CIF.CIFFile()
     cif_file.load_file(filobj)
     if len(cif_file.data_blocks) != 1:
         warning("read_start: only single-structure CIF files supported")
         self.halt = True
         return
     self.cif = cif_file.data_blocks[0]
     self.get_cell_parameters()
     self.atom_site_name_map = {}
Ejemplo n.º 4
0
    def get_cell_parameters(self):
        """Read unit information form various tags and compute
        the fractional-to-Cartesian conversion matrix.
        """
        a = CIF.makeNumber(self.cif.tags["cell_length_a"])
        b = CIF.makeNumber(self.cif.tags["cell_length_b"])
        c = CIF.makeNumber(self.cif.tags["cell_length_c"])
        alpha_degrees = CIF.makeNumber(self.cif.tags["cell_angle_alpha"])
        beta_degrees = CIF.makeNumber(self.cif.tags["cell_angle_beta"])
        gamma_degrees = CIF.makeNumber(self.cif.tags["cell_angle_gamma"])
        z = self.cif.tags["cell_formula_units_z"]
        space_group = self.cif.tags.get("symmetry_space_group_name_h-m", None)
        unit_cell = {
            "length_a": a,
            "length_b": b,
            "length_c": c,
            "angle_alpha": alpha_degrees,
            "angle_beta": beta_degrees,
            "angle_gamma": gamma_degrees,
            "z": z,
            "space_group": space_group
        }
        self.load_unit_cell(unit_cell)

        #
        # Transformation matrix from
        # http://www.ccl.net/cca/documents/molecular-modeling/node4.html
        #
        import math
        alpha = math.radians(alpha_degrees)
        cosa = math.cos(alpha)
        sina = math.sin(alpha)
        beta = math.radians(beta_degrees)
        cosb = math.cos(beta)
        sinb = math.sin(beta)
        gamma = math.radians(gamma_degrees)
        cosg = math.cos(gamma)
        sing = math.sin(gamma)
        V = a * b * c * math.sqrt(1 - cosa * cosa - cosb * cosb - cosg * cosg +
                                  2 * cosa * cosb * cosg)
        self.xform = [
            [a, b * cosg, c * cosb],
            [0, b * sing, c * (cosa - cosb * cosg) / sing],
            [0, 0, V / (a * b * sing)],
        ]
Ejemplo n.º 5
0
    def get_cell_parameters(self):
        """Read unit information form various tags and compute
        the fractional-to-Cartesion conversion matrix.
        """
        a = CIF.makeNumber(self.cif.tags["cell_length_a"])
        b = CIF.makeNumber(self.cif.tags["cell_length_b"])
        c = CIF.makeNumber(self.cif.tags["cell_length_c"])
        alpha_degrees = CIF.makeNumber(self.cif.tags["cell_angle_alpha"])
        beta_degrees = CIF.makeNumber(self.cif.tags["cell_angle_beta"])
        gamma_degrees = CIF.makeNumber(self.cif.tags["cell_angle_gamma"])
        z = self.cif.tags["cell_formula_units_z"]
        space_group = self.cif.tags.get("symmetry_space_group_name_h-m", None)
        unit_cell = {
            "length_a": a,
            "length_b": b,
            "length_c": c,
            "angle_alpha": alpha_degrees,
            "angle_beta": beta_degrees,
            "angle_gamma": gamma_degrees,
            "z": z,
            "space_group": space_group
        }
        self.load_unit_cell(unit_cell)

        #
        # Transformation matrix from
        # http://www.ccl.net/cca/documents/molecular-modeling/node4.html
        #
        import math
        alpha = math.radians(alpha_degrees)
        cosa = math.cos(alpha)
        sina = math.sin(alpha)
        beta = math.radians(beta_degrees)
        cosb = math.cos(beta)
        sinb = math.sin(beta)
        gamma = math.radians(gamma_degrees)
        cosg = math.cos(gamma)
        sing = math.sin(gamma)
        V = a * b * c * math.sqrt(1 - cosa * cosa - cosb * cosb
                                    - cosg * cosg + 2 * cosa * cosb * cosg)
        self.xform = [
            [ a, b * cosg, c * cosb ],
            [ 0, b * sing, c * (cosa - cosb * cosg) / sing ],
            [ 0, 0,        V / (a * b * sing) ],
        ]
Ejemplo n.º 6
0
import CIF
circuit = CIF.Circuit("Transistor", "micro", 0.001)
poly1 = CIF.Polygon(6)
poly1.addPoint(130, 290)
poly1.addPoint(540, 290)
poly1.addPoint(540, 690)
poly1.addPoint(130, 690)
circuit.addPolygon(poly1)

poly2 = CIF.Polygon(17)
poly2.addPoint(305, 150)
poly2.addPoint(365, 150)
poly2.addPoint(365, 830)
poly2.addPoint(305, 830)
circuit.addPolygon(poly2)

circuit.writeToFile("./transistor.cif")