def run(num=1, time=30, direct = 'profile_data/test/'): startup.init(False) #False = no splash screen #Startup has to happen before other imports that use resources. from core import player from core.game import game #Filenames field_file = DEF.FIELD_FILE_DIRECTORY + "_benchmark.utf" files = [] FPS = [] for n in xrange(0, num): #Setup the game data. player_descriptors = [] player_descriptors.append(player.PlayerDescriptor(DEF.PTYPE_CPU,team=1)) player_descriptors[0].name = "Player" for i in range(0,15): player_descriptors.append(player.PlayerDescriptor(DEF.PTYPE_CPU,team=i+2)) player_descriptors[i+1].name = DEF.PLAYER_NAMES[i] #Run and profile. direct if not os.path.exists(direct): os.makedirs(direct) files.append(direct + PREFIX+ "_%d.prof" % n) GAME = game.Game(field_file, player_descriptors) cProfile.runctx("FPS.append(run_game(GAME, time))", globals(), {'GAME':GAME, 'FPS':FPS, 'time':time}, files[n]) startup.close() return files, FPS
def run(): """Run the Program""" print "Initialization..." startup.init() print "Initialization Done" import core.utils.definitions as DEF from core.menus import main_menu if DEF.PROFILE: import hotshot PROFILER = hotshot.Profile(DEF.PROFILER_FILE) if DEF.PROFILE: PROFILER.start() main_menu.MainMenu().run() #Cleanup. print "Quiting...", if DEF.PROFILE: PROFILER.stop() PROFILER.close() startup.close() print "Done"
import time import datetime import os import teias_control debug = os.getenv('DEBUG', 'false') if debug == 'true': recipients = ["*****@*****.**"] else: recipients = ["*****@*****.**"] print("starting.Debug is :" + debug) startup.tpys() startup.init() var = 1 while var == 1: if debug == 'true': time.sleep(10) else: time.sleep(600) if control.is_there_new_announce(0) == 1: screenshot.print_announcement(control.take_link(0)) for recipient in recipients: mail.sendmail(recipient, control.take_link(0)) startup.init() else:
from startup import init if __name__ == '__main__': init()
def main(): # fn = sys.argv[1] # read_input(fn) if glb.restart: read_restart() else: init(rotate=True) # First energy calc glb.box_energy, loverlap = sumup(lrecip=True) glb.energy_nokspace, loverlap = sumup(lrecip=False) energy_acc = [] trans_acc = [] rot_acc = [] # Decide whether to continue run or overwrite write_xyz("ewald-test.xyz", (not glb.continue_run)) # Monte Carlo! for cycle in range(glb.number_of_cycles): for step in range(glb.number_of_molecules): # Pick what kind of move to perform move = np.random.random() if move < glb.trans_prob: t = trans_move() trans_acc.append(t) else: r = rigid_rot_move() rot_acc.append(r) if cycle % glb.iwrite == 0: write_xyz("ewald-test.xyz", False) if cycle % glb.ienrg == 0: etmp, lovr = sumup(lrecip=True) energy_acc.append(etmp) # Overwrite last restart file write_xyz("restart.xyz", True) if glb.number_of_cycles > 0: with open("ewald-test.out", "w") as out: out.write("Simulation Information\n") out.write("Number of molecules: {}\n".format( glb.number_of_molecules)) out.write("Temperature [K]: {}\n".format(glb.temperature)) out.write("Box Length [A]: {}\n".format(glb.box_length)) out.write("\nForce Field Information\n") out.write("Coulomb Calc. Type: {}\n".format(glb.qtype)) if glb.qtype == "Ewald": out.write("num. k vectors: {}\n".format(glb.nkvec)) out.write("Tail Corrections: {}\n".format(glb.ltailc)) out.write("\nResults\n") out.write("Trans. Acceptance : {:<16.4f}\n".format( np.mean(trans_acc) * 100)) out.write("Rot. Acceptance : {:<16.4f}\n".format( np.mean(rot_acc) * 100)) out.write("Average Energy [K]: {:<16.4f} {:<16.4f}\n".format( np.mean(energy_acc), np.std(energy_acc, ddof=1)))