예제 #1
0
def main():
    structure = XYZ()
    structure.load(structure_file)

    atom_numbers = get_atom_numbers_by_z_range(structure.rows, surface_z_min,
                                               surface_z_max)

    f = file(output_file, 'w')
    for atom_number in atom_numbers:
        f.write(str(atom_number) + "\n")
    f.close()
def main():
    structure = XYZ()
    structure.load(structure_file)
    
    atom_numbers = get_atom_numbers_by_z_range(
        structure.rows, surface_z_min, surface_z_max
    )

    f = file(output_file, 'w')
    for atom_number in atom_numbers:
        f.write(str(atom_number)+"\n")
    f.close()
예제 #3
0
def main():
    structure = XYZ()
    structure.load(structure_file)

    structure.set_rows(
        get_atoms_by_z_range(structure.rows, surface_z_min, surface_z_max))

    structure.export(output_file)
def main():
    structure = XYZ()
    structure.load(structure_file)
    
    structure.set_rows(
        get_atoms_by_z_range(structure.rows, surface_z_min, surface_z_max)
    )

    structure.export(output_file)
예제 #5
0
    def initialize(self):
        self.number_of_target_atoms = Struct()
        self.number_of_target_atoms.x = len(self.molecule_placement[0])
        self.number_of_target_atoms.y = len(self.molecule_placement)

        self.spacing_of_target_atoms = Struct()
        self.spacing_of_target_atoms.x = abs(self.upper_left_surface_atom.x- \
         self.lower_right_surface_atom.x)/(self.number_of_target_atoms.x-1) #-1 because counting atom connections
        self.spacing_of_target_atoms.y = abs(self.upper_left_surface_atom.y- \
         self.lower_right_surface_atom.y)/(self.number_of_target_atoms.y-1) #-1 because counting atom connections

        #Load our surface and molecule placing position
        self.surface = XYZ()
        self.surface.load(self.surface_xyz_file)

        self.place_molecule = XYZ()
        self.place_molecule.load(self.place_xyz_file)
        self.place_molecule.normalize_coordinates(
        )  #Make the molecule start from (0,0,0)
        #Make the molecule start from the upper left position
        self.place_molecule.translate(self.upper_left_surface_atom.x, self.upper_left_surface_atom.y,  \
         self.upper_left_surface_atom.z)
예제 #6
0
    def initialize(self):
        self.number_of_target_atoms = Struct()
        self.number_of_target_atoms.x = len(self.molecule_placement[0])
        self.number_of_target_atoms.y = len(self.molecule_placement)

        self.spacing_of_target_atoms = Struct()
        self.spacing_of_target_atoms.x = abs(self.upper_left_surface_atom.x - self.lower_right_surface_atom.x) / (
            self.number_of_target_atoms.x - 1
        )  # -1 because counting atom connections
        self.spacing_of_target_atoms.y = abs(self.upper_left_surface_atom.y - self.lower_right_surface_atom.y) / (
            self.number_of_target_atoms.y - 1
        )  # -1 because counting atom connections

        # Load our surface and molecule placing position
        self.surface = XYZ()
        self.surface.load(self.surface_xyz_file)

        self.place_molecule = XYZ()
        self.place_molecule.load(self.place_xyz_file)
        self.place_molecule.normalize_coordinates()  # Make the molecule start from (0,0,0)
        # Make the molecule start from the upper left position
        self.place_molecule.translate(
            self.upper_left_surface_atom.x, self.upper_left_surface_atom.y, self.upper_left_surface_atom.z
        )
예제 #7
0
import XYZ
from datetime import date

inputs = {'uid' : 12345,
          'issue' : date(2016, 1, 1),    
          'maturity' : date(2026, 1, 1),
          'CouponFreq' : 2,
          'coupon' : 0.05,
          'price' : 115,
          'PricingDate' : date(2016, 11, 17)
}

b = XYZ.Bond(inputs)
b.Print()
print('-----------------------------------')

b.verbose = True
p = b.YieldToPrice(0.05)
b.verbose = False
clean = b.YieldToPrice(0.05, clean=True)
print('Dirty Price : ', "{:10.4f}%".format(p*100))
print('Clean Price : ', "{:10.4f}%".format(clean*100))
print('    Accrued : ', "{:10.4f}%".format(b.data['accrued']*100))
print('-----------------------------------')

y = b.PriceToYield(p)
print('Yield : ', "{:10.4f}%".format(y*100))

b.data['yield'] = y
delta = b.Duration()
print('Delta : ', "{:10.4f}".format(delta))
예제 #8
0
class Surface_place:
    def __init__(self):
        pass

    def set_filenames(self, in_surface_file, in_place_file, in_output_file):
        self.surface_xyz_file = in_surface_file
        self.place_xyz_file = in_place_file  # The molecule we want to place on the surface
        self.output_xyz_file = in_output_file

    def define_surface_sites(self, in_upper_left, in_lower_right, in_z_dist):
        self.upper_left_surface_atom = in_upper_left  # In Angstroms
        self.lower_right_surface_atom = in_lower_right
        self.placement_z_distance_from_surface = in_z_dist

    def define_molecule_placement(self, in_placement_config):
        self.molecule_placement = in_placement_config

    def initialize(self):
        self.number_of_target_atoms = Struct()
        self.number_of_target_atoms.x = len(self.molecule_placement[0])
        self.number_of_target_atoms.y = len(self.molecule_placement)

        self.spacing_of_target_atoms = Struct()
        self.spacing_of_target_atoms.x = abs(self.upper_left_surface_atom.x - self.lower_right_surface_atom.x) / (
            self.number_of_target_atoms.x - 1
        )  # -1 because counting atom connections
        self.spacing_of_target_atoms.y = abs(self.upper_left_surface_atom.y - self.lower_right_surface_atom.y) / (
            self.number_of_target_atoms.y - 1
        )  # -1 because counting atom connections

        # Load our surface and molecule placing position
        self.surface = XYZ()
        self.surface.load(self.surface_xyz_file)

        self.place_molecule = XYZ()
        self.place_molecule.load(self.place_xyz_file)
        self.place_molecule.normalize_coordinates()  # Make the molecule start from (0,0,0)
        # Make the molecule start from the upper left position
        self.place_molecule.translate(
            self.upper_left_surface_atom.x, self.upper_left_surface_atom.y, self.upper_left_surface_atom.z
        )

    def place(self):
        for row_index, row in enumerate(self.molecule_placement):
            for spot_index, each_spot in enumerate(row):
                # We check for any list type first so that we can make modifications
                # before doing translation and placing.
                if each_spot != 0:
                    temp_place_molecule = copy.deepcopy(self.place_molecule)

                if [].__class__ == type(each_spot):  # If it is a list
                    print "Rotating molecule: " + str(each_spot[1])
                    # Rotate the molecule
                    temp_place_molecule.rotate_wrt_atom(each_spot[1], each_spot[2], each_spot[3])
                    each_spot = each_spot[0]  # Set equal to just an integer so we can translate it later

                    # if type(1) == type(each_spot): #If integer
                if each_spot == 1:
                    print "Placing molecule at: (" + str(spot_index) + ", " + str(row_index) + ")"
                    # We have a spot marked for placement. Let's place the molecule
                    # Note: We *must* use deepcopy since the XYZ class uses lists which
                    #      are references.
                    temp_place_molecule.translate(  # In initialize, we already translated to upper left position.
                        spot_index * self.spacing_of_target_atoms.x,
                        row_index * self.spacing_of_target_atoms.y,
                        self.placement_z_distance_from_surface,
                    )
                    # print spot_index * self.spacing_of_target_atoms.x
                    # print row_index * self.spacing_of_target_atoms.y
                    # print self.placement_z_distance_from_surface
                    self.surface.add(temp_place_molecule)
                    del temp_place_molecule  # Don't need it since we added to the surface
예제 #9
0
class Surface_place:
    def __init__(self):
        pass

    def set_filenames(self, in_surface_file, in_place_file, in_output_file):
        self.surface_xyz_file = in_surface_file
        self.place_xyz_file = in_place_file  #The molecule we want to place on the surface
        self.output_xyz_file = in_output_file

    def define_surface_sites(self, in_upper_left, in_lower_right, in_z_dist):
        self.upper_left_surface_atom = in_upper_left  #In Angstroms
        self.lower_right_surface_atom = in_lower_right
        self.placement_z_distance_from_surface = in_z_dist

    def define_molecule_placement(self, in_placement_config):
        self.molecule_placement = in_placement_config

    def initialize(self):
        self.number_of_target_atoms = Struct()
        self.number_of_target_atoms.x = len(self.molecule_placement[0])
        self.number_of_target_atoms.y = len(self.molecule_placement)

        self.spacing_of_target_atoms = Struct()
        self.spacing_of_target_atoms.x = abs(self.upper_left_surface_atom.x- \
         self.lower_right_surface_atom.x)/(self.number_of_target_atoms.x-1) #-1 because counting atom connections
        self.spacing_of_target_atoms.y = abs(self.upper_left_surface_atom.y- \
         self.lower_right_surface_atom.y)/(self.number_of_target_atoms.y-1) #-1 because counting atom connections

        #Load our surface and molecule placing position
        self.surface = XYZ()
        self.surface.load(self.surface_xyz_file)

        self.place_molecule = XYZ()
        self.place_molecule.load(self.place_xyz_file)
        self.place_molecule.normalize_coordinates(
        )  #Make the molecule start from (0,0,0)
        #Make the molecule start from the upper left position
        self.place_molecule.translate(self.upper_left_surface_atom.x, self.upper_left_surface_atom.y,  \
         self.upper_left_surface_atom.z)

    def place(self):
        for row_index, row in enumerate(self.molecule_placement):
            for spot_index, each_spot in enumerate(row):
                #We check for any list type first so that we can make modifications
                #before doing translation and placing.
                if each_spot != 0:
                    temp_place_molecule = copy.deepcopy(self.place_molecule)

                if [].__class__ == type(each_spot):  #If it is a list
                    print 'Rotating molecule: ' + str(each_spot[1])
                    #Rotate the molecule
                    temp_place_molecule.rotate_wrt_atom(
                        each_spot[1], each_spot[2], each_spot[3])
                    each_spot = each_spot[
                        0]  #Set equal to just an integer so we can translate it later

                #if type(1) == type(each_spot): #If integer
                if each_spot == 1:
                    print 'Placing molecule at: (' + str(
                        spot_index) + ', ' + str(row_index) + ')'
                    #We have a spot marked for placement. Let's place the molecule
                    #Note: We *must* use deepcopy since the XYZ class uses lists which
                    #      are references.
                    temp_place_molecule.translate(  #In initialize, we already translated to upper left position.
                        spot_index * self.spacing_of_target_atoms.x,
                        row_index * self.spacing_of_target_atoms.y,
                        self.placement_z_distance_from_surface)
                    #print spot_index * self.spacing_of_target_atoms.x
                    #print row_index * self.spacing_of_target_atoms.y
                    #print self.placement_z_distance_from_surface
                    self.surface.add(temp_place_molecule)
                    del temp_place_molecule  #Don't need it since we added to the surface