def __init__(self): QtGui.QWidget.__init__(self) self.resize(640,480) self.setWindowTitle("MC Simulation of Protein A (1BDD)") topLevelLayout = QtGui.QHBoxLayout() sideBarLayout = QtGui.QVBoxLayout() self.maxSweeps = 1000 self.myU = universe.Universe() self.p = protein.Protein('../1bdd.seq') self.myMC = algorithms.CanonicalMonteCarlo(self.myU, 1, self.maxSweeps) self.myWorkThread = WorkThread(self.myMC.sweep) self.labelList = [['E', self.p.energy], ['R<sub>gyr</sub>', self.p.rgyr, 0], ['hb' ,self.p.hbond]] myCAlphaTraceWidget = CAlphaTraceWidget(self.p) topLevelLayout.addWidget(myCAlphaTraceWidget, 1) self.createSideBar(sideBarLayout) topLevelLayout.addLayout(sideBarLayout) self.setLayout(topLevelLayout) self.myWorkThread.start() self.connect(self.myWorkThread, QtCore.SIGNAL("finishedSweep(int)"), self.finishedSweep) self.connect(self.myWorkThread, QtCore.SIGNAL("finishedSweep(int)"), self.myProgressBar, QtCore.SLOT("setValue(int)"))
def LearnNewSchema(filename): f_in = open(filename) jsonString = f_in.read() f_in.close() del f_in f_backup = open(filename + ".bak", 'w') f_backup.write(jsonString) f_backup.close() del f_backup import universe jsonString = Config.FromJson(jsonString, universe.Universe()).ToJson() f_out = open(filename, 'w') f_out.write(jsonString) f_out.close() del f_out
def create_universe(self): """ This function creates a universe object that simulations will run in. :return u: the universe for the simulation to run in :rtype: universe.Universe """ # set up universe u = universe.Universe(self.params.num_steps, self.params.dt, self.params.t_start, self.params.num_people) # set the clock to the desired start time u.clock.t_univ = self.params.t_start u.clock.set_time() return u
def __init__(self, hhld_params): # the scenario identifier self.id = NO_SIMULATION # kew word arguments # probably will need to access various features of kwarg in the future when the model # becomes more complex self.params = hhld_params # create the universe object self.u = universe.Universe(self.params.num_steps, self.params.dt, t_start=self.params.t_start, \ num_people=self.params.num_people) # set the clock to the desired time self.u.clock.t_univ = self.params.t_start self.u.clock.set_time() return
def segment_graph(num_vertices, edges, k): """ felzenswalb segmenation algo :param num_vertices: number of vertices :param edges: graph/ list of edges :param k: threshold parameter :return: univ: segmented graph """ # sort edges by weight edges = sorted(edges, key=lambda _edge: _edge.w) # make a disjoint-set forest u = universe.Universe(num_vertices) # init thresholds thres = [] for i in range(0, num_vertices): thres.append(threshold(1, k)) # for each edge, in non-decreasing weight order... joined = 0 for i in range(0, len(edges)): pedge = edges[i] # components connected by this edge a = u.find(pedge.a) b = u.find(pedge.b) if a != b: if (pedge.w <= thres[a]) and (pedge.w <= thres[b]): # w < min(Int(C1)+threshold(C1),Int(C2+threshold(C2)) joined += 1 u.join(a, b) a = u.find(a) thres[a] = pedge.w + threshold(u.get_size(a), k) # Int(a) = max weight in a. As edge is sorted, pedge.w = max weight belonging to the comp a return u
def getUniverse(self): print("Creating the universe...") self.universe = universe.Universe(self.savefile, self.hoi4path) print("Establishing history...") self.universe.Load()
universe.sizeNullAvion) for xyFeatherAvion in universe.xyFeatherAvions: pg.draw.circle(self.screen, self.colors['featherAvion'], xyFeatherAvion, universe.sizeFeatherAvion) pg.display.flip() def tickClock(self): self.clock.tick(self.maxFPS) def quit(self): self.running = False universe = u.Universe() universe.addParticles(type_='hyperAvion', num=2, energy=3.0) universe.addParticles(type_='nullAvion', num=2, energy=3.0) universe.addParticles(type_='featherAvion', num=2, energy=3.0) if __name__ == '__main__': visual = Visualiser(universe.size) while visual.running: for event in pg.event.get(): if event.type == pg.QUIT: visual.quit() universe.step() #print(universe.xyNullAvions, 'null')
def getUniverse(self): print("Creating the universe...") self.universe = universe.Universe(Config().getSaveData()) print("Establishing history...") self.universe.Load()
def play_game(i, name): game = universe.Universe(i, name) game.play_loop() print "game process ending." return True
import universe import argparse import tqdm import random output_dir = "./evolutions" parser = argparse.ArgumentParser() parser.add_argument("--NEpochs", help="number of epochs to be placed", type=int) parser.add_argument("--InitialFile", help="file with the initial conditions", type=str) parser.add_argument("--OutputFile", help="file with the initial conditions", type=str) parser.add_argument("--NDims", help="dimension of random field", type=int, default=100) args = parser.parse_args() universes = [] universes.append(universe.Universe(0)) if args.InitialFile=="random": print "Generating random input..." tmppath = "initials/random.txt" with open(tmppath, "w") as infile: for nx in range(args.NDims): for ny in range(args.NDims): value = 1 if random.uniform(0., 100.) < 30. else 0 infile.write("%i "%value) infile.write("\n") universes[0].InitialiseFromFile(tmppath) import os else: universes[0].InitialiseFromFile(args.InitialFile)
def getUniverse(locationOfLiveCells=None): return universe.Universe(locationOfLiveCells)
def ValidateSchema(filename): f_in = open(filename) jsonString = f_in.read() f_in.close() import universe jsonString = Config.FromJson(jsonString, universe.Universe()).ToJson()
def __init__(self): self.universe = universe.Universe() self.player = None
au = 1.486 * (10**11) day = 60 * 60 * 24 year = 365.242 * day Sun = uni.Planet("Sun", "yellow", 1.989 * (10**30), np.array((0, 0)), np.array((0, 0))) Mercury = uni.Planet("Mercury", "orange", 3.3 * (10**24), np.array( (-47362, 0)), np.array((0, 0.466 * au))) Venus = uni.Planet("Venus", "red", 4.8685 * (10**24), np.array((0, 35020)), np.array((0.723 * au, 0))) Earth = uni.Planet("Earth", "blue", 5.9742 * (10**24), np.array((0, -29783)), np.array((-1 * au, 0))) Mars = uni.Planet("Mars", "brown", 6.417 * (10**23), np.array((24007, 0)), np.array((0, -1.667 * au))) p = uni.Universe() p.addPlanet(Sun) p.addPlanet(Mercury) p.addPlanet(Venus) p.addPlanet(Earth) p.addPlanet(Mars) p.interact(5 * year) fig = plt.figure("Sunvec sustav") axis = plt.axes(xlim=(-2 * au, 2 * au), ylim=(-2 * au, 2 * au)) axis.plot(Sun.x_, Sun.y_, c=Sun.color, label=Sun.name, linewidth=2) axis.plot(Mercury.x_, Mercury.y_, c=Mercury.color, label=Mercury.name) axis.plot(Venus.x_, Venus.y_, c=Venus.color, label=Venus.name) axis.plot(Earth.x_, Earth.y_, c=Earth.color, label=Earth.name)
import matplotlib.pyplot as plt import matplotlib.animation as animation au = 1.496e11 day = 60 * 60 * 24 year = 365.242 * day sun = universe.Planet("Sun", 1.989e30, np.array((0., 0.)), np.array((0., 0.))) earth = universe.Planet("Earth", 5.9742e24, np.array((-1 * au, 0.)), np.array((0., 29783.))) mercury = universe.Planet("Mercury", 3.3e24, np.array((0, 0.466 * au)), np.array((-47362., 0.))) venus = universe.Planet("Venus", 4.8685e24, np.array((0.723 * au, 0.)), np.array((0., 35020.))) mars = universe.Planet("Mars", 6.417e23, np.array((0., -1.666 * au)), np.array((24007., 0.))) ss = universe.Universe() ss.add_planet(sun) ss.add_planet(earth) ss.add_planet(mercury) ss.add_planet(venus) ss.add_planet(mars) ss.evolve(5.0 * year) fig = plt.figure(figsize=(10, 10)) plt.plot(sun.x, sun.y, label=sun.name, color="yellow", linewidth=5.0) plt.plot(earth.x, earth.y, label=earth.name, color="blue") plt.plot(mars.x, mars.y, label=mars.name, color="red") plt.plot(mercury.x, mercury.y, label=mercury.name, color="orange") plt.plot(venus.x, venus.y, label=venus.name, color="green") plt.scatter(earth.x[-1], earth.y[-1])
# Copyright 2007 Frank Eisenmenger, U.H.E. Hansmann, # Jan H. Meinke, Sandipan Mohanty # """Minimize the energy of met-enkaphalin starting from a given structure using conjugate gradient. """ # Adds the source directory to Python's search path. import sys sys.path.append('../..') import smmp, universe, protein # Initialize the Universe to T=300K with the ECEPP/3 force field, no solvent # term (st = 0) and the sub directory SMMP/ as library path. Except for the # solvent term, these are the default values. Alternatively, we could have # written # myUniverse = universe.Universe(st=0) # to get the same result. myUniverse = universe.Universe(T=300, ff='ecepp3', st=0, libdir='SMMP/') # Create a new protein object from the sequence file ../enkefa.seq and # set the dihedral angles according to the values given in ../enkefa.var. p = protein.Protein('../1bdd.pdb') # Make myUniverse aware of p. myUniverse.add(p) maxNumberOfIterations = 10 maxNumberOfSweepsPerIteration = 15000 desiredPrecision = 1.0e-7 smmp.regul(1, maxNumberOfIterations, maxNumberOfSweepsPerIteration, desiredPrecision)
def setUp(self): cur_universe = universe.Universe("Voie lactée") self.player = Player("Thomas", cur_universe)
vels = v_scale * unit_pos2com vels = rotate(vels) for k in range(n): params = [new_pos_x[k], new_pos_y[k], vels[k][0], vels[k][1], mass] for ii in range(len(params)): if params[ii] < 0.0: f.write(str(params[ii]) + ' ') else: f.write(' ' + str(params[ii]) + ' ') f.write('\n') f.close() universe = u.Universe("temp_data.txt") for j in range(500): universe.increaseTime(dt) stddraw.clear() universe.draw() stddraw.show(10) x_arr = universe._xtracks y_arr = universe._ytracks #coords = zip(x_array_p[n],y_array_p) img_rows, img_cols = 110, 110 #imgs = np.zeros((n, img_rows, img_cols))
w, h = img.get_size() pos = ((WIDTH / 2) - (w / 2), (HEIGHT / 2) - (h / 2)) screen.blit(img, pos) if __name__ == "__main__": # Title Screen show_title_screen() # Main menu option = show_main_menu() # TODO: only update dirty rects if option == "new game": playing = True dimension = universe.Universe("MagistarHeroes") # this is the seed planet = dimension.galaxies[0].solars[0].planets[0] player = character.Character('mage', (20, 200), proxy(game_objects), 'Player') #player.stats.upStat("fire") #game_objects['player'] = player while playing: # Game loop # Handle events keys = [] for event in pygame.event.get(): if event.type == pygame.QUIT: playing = False elif event.type == pygame.KEYDOWN: