def generateOutputs():
    command = "rm *.aei"
    (stdout, stderr, returnCode) = autiwa.lancer_commande(command)

    # We want to know the name of the machine, to adapt the way we will launch the simulations in function
    hostname = simulations_utilities.getHostname()
    command = BINARY_FOLDER[hostname] + "/element"

    (stdout, stderr, returnCode) = autiwa.lancer_commande(command)
def generateOutputs():
  command = "rm *.aei"
  (stdout, stderr, returnCode) = autiwa.lancer_commande(command)

  # We want to know the name of the machine, to adapt the way we will launch the simulations in function
  hostname = simulations_utilities.getHostname()
  command = BINARY_FOLDER[hostname]+"/element"
  
  (stdout, stderr, returnCode) = autiwa.lancer_commande(command)
def getHostname():
  """This function will return the machine name as a string. 
  For instance, if the machine name is arguin, and that I get arguin.obs.u-bordeaux1.fr, I can test that with :
  if ('arguin' in hostname):
  """
  
  (stdout, stderr, returnCode) = autiwa.lancer_commande("hostname")
  hostname = stdout.split("\n")[0]
  
  return hostname
def getHostname():
    """This function will return the machine name as a string. 
  For instance, if the machine name is arguin, and that I get arguin.obs.u-bordeaux1.fr, I can test that with :
  if ('arguin' in hostname):
  """

    (stdout, stderr, returnCode) = autiwa.lancer_commande("hostname")
    hostname = stdout.split("\n")[0]

    return hostname
def mercury_continue():
    """function that will continue an existing simulation that did not have time to finish
  """
    command = "rm *.aei *.clo"
    print("\tCleaning the simulation files : %s" % command)
    (stdout, stderr, returnCode) = autiwa.lancer_commande(command)

    command = "./runjob"
    print("\tStarting the simulation again : %s" % command)
    job = subprocess.Popen(command, shell=True)
    returnCode = job.wait()
def mercury_continue():
  """function that will continue an existing simulation that did not have time to finish
  """
  command = "rm *.aei *.clo"
  print("\tCleaning the simulation files : %s" % command)
  (stdout, stderr, returnCode) = autiwa.lancer_commande(command)

  command = "./runjob"
  print("\tStarting the simulation again : %s" % command)
  job = subprocess.Popen(command, shell=True)
  returnCode = job.wait()
def get_aei_files():
  """function that return the list of *.aei files of the current folder"""
  (process_stdout, process_stderr, return_code) = autiwa.lancer_commande("ls *.aei")
  if (return_code != 0):
    print("the command return an error "+str(return_code))
    print(process_stderr)
    exit()
    
  liste_aei = process_stdout.split("\n")
  liste_aei.remove('') # we remove an extra element that doesn't mean anything
  return liste_aei
def get_aei_files():
    """function that return the list of *.aei files of the current folder"""
    (process_stdout, process_stderr,
     return_code) = autiwa.lancer_commande("ls *.aei")
    if (return_code != 0):
        print("the command return an error " + str(return_code))
        print(process_stderr)
        exit()

    liste_aei = process_stdout.split("\n")
    liste_aei.remove(
        '')  # we remove an extra element that doesn't mean anything
    return liste_aei
def mercury_restart():
  """function that will restart a simulation. That means cleaning the existing file, 
  and launch the simulation again, from the start
  """
  
  # For each folder were there is a problem (NaN in the output in other words) we clean and relaunch the simulation
  command = "rm *.out *.dmp *.tmp *.sh.* *.aei *.clo"
  print("\tCleaning the simulation files : %s" % command)
  (stdout, stderr, returnCode) = autiwa.lancer_commande(command)
  
  command = "./runjob"
  print("\tContinuing the simulation to allow it to finish properly : %s" % command)
  job = subprocess.Popen(command, shell=True)
  returnCode = job.wait()
def mercury_restart():
    """function that will restart a simulation. That means cleaning the existing file, 
  and launch the simulation again, from the start
  """

    # For each folder were there is a problem (NaN in the output in other words) we clean and relaunch the simulation
    command = "rm *.out *.dmp *.tmp *.sh.* *.aei *.clo"
    print("\tCleaning the simulation files : %s" % command)
    (stdout, stderr, returnCode) = autiwa.lancer_commande(command)

    command = "./runjob"
    print("\tContinuing the simulation to allow it to finish properly : %s" %
          command)
    job = subprocess.Popen(command, shell=True)
    returnCode = job.wait()
def erase_aei():
  """supress all the .aei files for each simulation"""
  
  command = "rm *.aei"
  (stdout, stderr, returnCode) = autiwa.lancer_commande(command)
Exemple #12
0
    else:
        print("the key '" + key + "' does not match")
        isProblem = True

if isProblem:
    print(problem_message)

if NB_FRAMES <= 1:
    print("The number of frames cannot be lower than 2")
    NB_FRAMES = 2

####################
# We erase old output files, add 'x, y and z' to the outputs values, and generate new output files
####################

autiwa.lancer_commande("rm *.aei element.out")

elementin = mercury.Element()
elementin.read()
elementin.set_format_sortie(" a21e e21e i8.4 g8.4 n8.4 l8.4 m21e x21e y21e z21e")
elementin.write()

(stdout, stderr, returnCode) = autiwa.lancer_commande(os.path.join(BINARY_FOLDER, "element"))
if returnCode != 0:
    print("Unable to Launch 'element'")

####################
# On recupere la liste des fichiers planetes.aei
####################
(process_stdout, process_stderr, return_code) = autiwa.lancer_commande("ls *.aei")
if return_code != 0:
  if (meta == '.'):
    absolute_parent_path = rep_exec
  else:
    absolute_parent_path = os.path.join(rep_exec, meta)
  
  # We get the list of simulations
  simu_list = [dir for dir in os.listdir(".") if (os.path.isdir(dir))]
  #autiwa.suppr_dossier(liste_simu,dossier_suppr)
  simu_list.sort()
  
  logs[meta] = []
  nb_simulations[meta] = len(simu_list)
  finished = 0 # We initialize the number of simulations finished for this meta simulation
  
  # We check which folders contain NaN
  (stdout, stderr, returnCode) = autiwa.lancer_commande('grep -l "NaN" */big.dmp')
  if (returnCode == 0):
    NaN_folder = stdout.split("/big.dmp\n")
    NaN_folder.remove('') # we remove an extra element that doesn't mean anything
  else:
    NaN_folder = []

  for simu in simu_list:
    os.chdir(simu)
    
    simulation_status = 0 # if 0, then the simulation ended correctly
    
    if not(os.path.isfile("param.in")):
      print("%s/%s : doesn't look like a regular simulation folder" % (absolute_parent_path, simu))
      print("\t 'param.in' does not exist, folder skipped")
      os.chdir("..")
    if (len(sys.argv) - 1) == 1:
        t_max = float(sys.argv[1])
    elif (len(sys.argv) - 1) == 2:
        t_min = float(sys.argv[1])
        t_max = float(sys.argv[2])
except:
    print(
        "If one argument, then this must be the max time for output. \nIf two arguments, the first is t_min and the second is t_max"
    )
    exit()

####################
# On récupère la liste des fichiers planètes.aei
####################
(process_stdout, process_stderr,
 return_code) = autiwa.lancer_commande("ls *.aei")
if (return_code != 0):
    print("the command return an error " + str(return_code))
    print(process_stderr)
    exit()

liste_aei = process_stdout.split("\n")
liste_aei.remove('')  # we remove an extra element that doesn't mean anything
nb_planete = len(liste_aei)

####################
# On lit, pour chaque planète, le contenu du fichier et on stocke les variables qui nous intéressent.
####################
t = []  # temps en année
m = []  # masse de la planète en masse terrestre
  elif (key == 'ext'):
    OUTPUT_EXTENSION = value
  elif (key == 'help'):
    isProblem = True
  else:
    print("the key '"+key+"' does not match")
    isProblem = True

if isProblem:
  print(problem_message)
  exit()

####################
# On récupère la liste des fichiers planètes.aei
####################
(process_stdout, process_stderr, return_code) = autiwa.lancer_commande("ls *.aei")
if (return_code != 0):
  print("the command return an error "+str(return_code))
  print(process_stderr)
  exit()
  
liste_aei = process_stdout.split("\n")
liste_aei.remove('') # we remove an extra element that doesn't mean anything
nb_planete = len(liste_aei)


####################
# On lit, pour chaque planète, le contenu du fichier et on stocke les variables qui nous intéressent.
####################
t = [] # temps en année
a = [] # demi-grand axe en ua
Exemple #16
0
def erase_aei():
    """supress all the .aei files for each simulation"""

    command = "rm *.aei"
    (stdout, stderr, returnCode) = autiwa.lancer_commande(command)
  elif (key == 'ext'):
    OUTPUT_EXTENSION = value
  elif (key == 'help'):
    isProblem = True
  else:
    print("the key '"+key+"' does not match")
    isProblem = True

if isProblem:
  print(problem_message)
  exit()

####################
# On récupère la liste des fichiers planètes.aei
####################
(process_stdout, process_stderr, return_code) = autiwa.lancer_commande("ls *.aei")
if (return_code != 0):
  print("the command return an error "+str(return_code))
  print(process_stderr)
  exit()
  
liste_aei = process_stdout.split("\n")
liste_aei.remove('') # we remove an extra element that doesn't mean anything
nb_planete = len(liste_aei)

####################
# On lit, pour chaque planete, le contenu du fichier et on stocke les variables qui nous intéressent.
####################
t = [] # time in years
a = [] # semi major axis in AU
e = [] # eccentricity
Exemple #18
0
    else:
        print("the key '" + key + "' does not match")
        isProblem = True

if isProblem:
    print(problem_message)

if (NB_FRAMES <= 1):
    print("The number of frames cannot be lower than 2")
    NB_FRAMES = 2

####################
# We erase old output files, add 'x, y and z' to the outputs values, and generate new output files
####################

autiwa.lancer_commande("rm *.aei element.out")

elementin = mercury.Element()
elementin.read()
elementin.set_format_sortie(
    " a21e e21e i8.4 g8.4 n8.4 l8.4 m21e x21e y21e z21e")
elementin.write()

(stdout, stderr,
 returnCode) = autiwa.lancer_commande(os.path.join(BINARY_FOLDER, "element"))
if (returnCode != 0):
    print("Unable to Launch 'element'")

####################
# On recupere la liste des fichiers planetes.aei
####################