def unstable_reaction_function(topology): recipe = readdy.StructuralReactionRecipe(topology) index = np.random.randint(0, len(topology.particles)) recipe.separate_vertex(index) recipe.change_particle_type(index, "Decay") recipe.change_particle_position(index, [0, 0, 0]) return recipe
def dissociation_reaction_function(topology): recipe = readdy.StructuralReactionRecipe(topology) edges = topology.get_graph().get_edges() edge = edges[1 + np.random.randint(0, len(edges) - 2)] recipe.remove_edge(edge) recipe.change_particle_type(edge[0].get().particle_index, "Head") recipe.change_particle_type(edge[1].get().particle_index, "Head") return recipe
def clean_sites_reaction_function(topology): recipe = readdy.StructuralReactionRecipe(topology) vertices = topology.get_graph().get_vertices() def search_configuration(): # dfs for finding configuration core-site-site-core for v1 in vertices: if topology.particle_type_of_vertex(v1) == "core": for v2_ref in v1.neighbors(): v2 = v2_ref.get() if topology.particle_type_of_vertex(v2) == "site": for v3_ref in v2.neighbors(): v3 = v3_ref.get() if v3.particle_index != v1.particle_index: if topology.particle_type_of_vertex( v3) == "site": for v4_ref in v3.neighbors(): v4 = v4_ref.get() if v4.particle_index != v2.particle_index: if topology.particle_type_of_vertex( v4) == "core": return v1.particle_index, v2.particle_index, v3.particle_index, v4.particle_index core1_p_idx, site1_p_idx, site2_p_idx, core2_p_idx = search_configuration( ) # find corresponding vertex indices from particle indices core1_v_idx = None site1_v_idx = None site2_v_idx = None core2_v_idx = None for i, v in enumerate(vertices): if v.particle_index == core1_p_idx and core1_v_idx is None: core1_v_idx = i elif v.particle_index == site1_p_idx and site1_v_idx is None: site1_v_idx = i elif v.particle_index == site2_p_idx and site2_v_idx is None: site2_v_idx = i elif v.particle_index == core2_p_idx and core2_v_idx is None: core2_v_idx = i else: pass if (core1_v_idx is not None) and (core2_v_idx is not None) and ( site1_v_idx is not None) and (site2_v_idx is not None): recipe.add_edge(core1_v_idx, core2_v_idx) recipe.separate_vertex(site1_v_idx) recipe.separate_vertex(site2_v_idx) recipe.change_particle_type(site1_v_idx, "dummy") recipe.change_particle_type(site2_v_idx, "dummy") else: raise RuntimeError("core-site-site-core wasn't found") return recipe
def intermediate_reaction_function(topology): recipe = readdy.StructuralReactionRecipe(topology) for v in topology.graph.vertices: recipe.change_particle_type(v, "unstable T") recipe.change_topology_type("unstable") return recipe
def reaction_fun(topology): return readdy.StructuralReactionRecipe(topology) \ .change_particle_type(0, "foo").change_particle_position(0, [0., 0., .1])
def reaction_function(topology): recipe = readdy.StructuralReactionRecipe(topology) if topology.get_n_particles() == 1: recipe.change_particle_type(0, "B") return recipe._get()
def reaction_function(topology): recipe = readdy.StructuralReactionRecipe(topology) if topology.get_n_particles() > 1: edge = np.random.randint(0, topology.get_n_particles() - 1) recipe.remove_edge(edge, edge + 1) return recipe._get()
def intermediate_reaction_function(topology): recipe = readdy.StructuralReactionRecipe(topology) for i in range(len(topology.get_graph().get_vertices())): recipe.change_particle_type(i, "unstable T") recipe.change_topology_type("unstable") return recipe
def flip2(topology): recipe = readdy.StructuralReactionRecipe(topology) for v in topology.graph.vertices: recipe.change_particle_type(v, "B") recipe.change_topology_type("T1") return recipe