예제 #1
0
def createfolder(subkey, initial):      
    inputfiles = os.listdir(directory)
    list.sort(inputfiles)
    x = 1
    archive = (os.path.dirname(os.path.dirname(runid)))
    # creates the name of the new folder using the subkey and value of that subkey used in that simulation
    newfolder = str(archive) + '/' + str(subkey) + '.' + str(initial) + '.' + str(x) + '/'


    while os.path.isdir(newfolder):
        x = x + 1
        newfolder = str(archive) + '/' + str(subkey) + '.' + str(initial) + '.' + str(x) + '/'
    else:
        shell("mkdir " + newfolder)
      # copies all the files across to a new folder
    for file in inputfiles:
        # copies control file, log, restart and dmp files as all start with BOUT.
        if file.startswith('BOUT.'):
            filepath = os.path.join(directory, file)
            if os.path.isfile(filepath):
                shutil.copy(filepath, newfolder)
        # copies the record file
        if file.startswith('record.'):
            filepath = os.path.join(directory, file)
            if os.path.isfile(filepath):
                shutil.copy(filepath, newfolder)
        # copies the usernotes file
        if file.startswith('usernotes.'):
            filepath = os.path.join(directory, file)
            if os.path.isfile(filepath):
                shutil.copy(filepath, newfolder)
    global loadfrom
    loadfrom = newfolder  
예제 #2
0
def launch(command,
           runcmd="mpirun -np",
           nproc=None,
           output=None,
           pipe=False,
           verbose=False):
    """Launch parallel MPI jobs
    
    status = launch(command, nproc, output=None)

    runcmd     Command for running parallel job; defaults to "mpirun -np"    
    command    The command to run (string)
    nproc      Number of processors (integer)
    output     Optional name of file for output
    """

    if nproc == None:
        # Determine number of CPUs on this machine
        nproc = determineNumberOfCPUs()

    cmd = runcmd + " " + str(nproc) + " " + command

    if output != None:
        cmd = cmd + " > " + output

    if verbose == True:
        print cmd

    return shell(cmd, pipe=pipe)
예제 #3
0
def launch(command, nproc=None, output=None, pipe=False):
    """Launch parallel MPI jobs
    
    status = launch(command, nproc, output=None)
    
    command    The command to run (string)
    nproc      Number of processors (integer)
    output     Optional name of file for output
    """

    if nproc == None:
        # Determine number of CPUs on this machine
        nproc = determineNumberOfCPUs()

    cmd = "mpirun -np " + str(nproc) + " " + command

    if output != None:
        cmd = cmd + " > " + output

    return shell(cmd, pipe=pipe)
예제 #4
0
파일: launch.py 프로젝트: LichengWang/BOUT
def launch(command, nproc=None, output=None, pipe=False):
    """Launch parallel MPI jobs
    
    status = launch(command, nproc, output=None)
    
    command    The command to run (string)
    nproc      Number of processors (integer)
    output     Optional name of file for output
    """
    
    if nproc == None:
        # Determine number of CPUs on this machine
        nproc = determineNumberOfCPUs()

    cmd = "mpirun -np " + str(nproc) + " " + command
    
    if output != None:
        cmd = cmd + " > "+output
    
    return shell(cmd, pipe=pipe)
예제 #5
0
파일: launch.py 프로젝트: AlxMar/BOUT-2.0
def launch(command, runcmd="mpirun -np", nproc=None, output=None, pipe=False, verbose=False):
    """Launch parallel MPI jobs
    
    status = launch(command, nproc, output=None)

    runcmd     Command for running parallel job; defaults to "mpirun -np"    
    command    The command to run (string)
    nproc      Number of processors (integer)
    output     Optional name of file for output
    """
    
    if nproc == None:
        # Determine number of CPUs on this machine
        nproc = determineNumberOfCPUs()

    cmd = runcmd + " " + str(nproc) + " " + command
    
    if output != None:
        cmd = cmd + " > "+output

    if verbose == True:
         print cmd    

    return shell(cmd, pipe=pipe)
예제 #6
0
    # No environment variable. Use default
    defaultArchive = os.getcwd() + '/Archive'
    if not os.path.isdir(defaultArchive):
        os.makedirs(defaultArchive)
    archive = defaultArchive

# Checks for a valid archive ID
def rundirectory(runid):   
    if os.path.exists(runid):
        print 'Valid runid', runid
    else:
        print 'Invalid runid', runid
        sys.exit(0)

# Makes a new directory called "tmp"
shell("mkdir " + directory) 
sourcedirectory = rundirectory(runid)



### directory = the runid
loadpath = directory + '/BOUT.inp'
loadfrom = runid

def scanPOWER(initial, limit, restart, loadpath, key, subkey, increment):
    
    global i, loadfrom
    inputfiles = os.listdir(loadfrom)
    for runfiles in inputfiles:
        filepath = os.path.join(loadfrom, runfiles)
        if os.path.isfile(filepath):
예제 #7
0
Lbar = 1.
Bbar = 1.
J0 = -J0 * shape.Bxy / (MU0 * Lbar)  # Turn into A/m^2
P0 = P0 * Bbar**2 / (2.0 * MU0)  # Pascals

shape.add(P0, "pressure")
shape.add(J0, "Jpar0")
shape.add(bxcvz, "bxcvz")

for nx in nxlist:
    # Generate a new mesh file

    filename = "grid%d.nc" % nx

    if isfile(filename):
        print("Grid file '%s' already exists" % filename)
    else:
        print("Creating grid file '%s'" % filename)
        f = DataFile(filename, create=True)
        shape.write(nx, nx, f)
        f.close()

    # Generate BOUT.inp file

    directory = "grid%d" % nx
    shell("mkdir " + directory)
    shell("cp data/BOUT.inp " + directory)
    shell("sed -i 's/MZ = 17/MZ = %d/g' %s/BOUT.inp" % (nx, directory))
    shell("sed -i 's/grid = \"grid16.nc\"/grid = \"%s\"/g' %s/BOUT.inp" %
          (filename, directory))
예제 #8
0
# Normalisation
Lbar = 1.
Bbar = 1.
J0 = - J0 * shape.Bxy / (MU0 * Lbar)  # Turn into A/m^2
P0 = P0 * Bbar**2 / (2.0*MU0)  # Pascals

shape.add(P0, "pressure")
shape.add(J0, "Jpar0")
shape.add(bxcvz, "bxcvz")

for nx in nxlist:
    # Generate a new mesh file
    
    filename = "grid%d.nc" % nx
    
    if isfile(filename):
        print("Grid file '%s' already exists" % filename)
    else:
        print("Creating grid file '%s'" % filename)
        f = DataFile(filename, create=True)
        shape.write(nx,nx, f)
        f.close()

    # Generate BOUT.inp file
    
    directory = "grid%d" % nx
    shell("mkdir " + directory)
    shell("cp data/BOUT.inp "+directory)
    shell("sed -i 's/MZ = 17/MZ = %d/g' %s/BOUT.inp" % (nx, directory))
    shell("sed -i 's/grid = \"grid16.nc\"/grid = \"%s\"/g' %s/BOUT.inp" % (filename, directory))