Esempio n. 1
0
    print >>script, "qsub %s.sh" % name
    print >>script, "cd .."

  os.chmod(script_path, 0755)

def make_magres_accum_script(root_dir, root_name, runs):
  script_path = os.path.join(root_dir, "magres_accum.sh")
  script = open(script_path, "w+")

  for target_dir, name in runs:
    print >>script, "grep isc %s/%s.magres >> %s-isc.magres" % (target_dir, name, root_name)

  os.chmod(script_path, 0755) 

if __name__ == "__main__":
  source_dir, name = calc_from_path(sys.argv[1])
  target_dir_prefix = sys.argv[2]
  s = sys.argv[3]
  i = int(sys.argv[4])

  if not os.path.isdir(target_dir_prefix):
    os.mkdir(target_dir_prefix)

  runs = []
  for x in [float(xp)/100.0 for xp in range(0,10)]:
    run_dir = "%s-%f" % (name, x)
    target_dir = os.path.join(target_dir_prefix, run_dir)

    if not os.path.isdir(target_dir):
      os.mkdir(target_dir)
Esempio n. 2
0
from castepy import calc
from castepy.util import calc_from_path, path

relax_path = path("templates/spectral")
merge_cell = cell.Cell(open(os.path.join(relax_path, "spectral.cell")).read())

def make(source_dir, source_name, target_dir):
  cal = calc.CastepCalc(source_dir, source_name)
  c = cell.Cell(cal.cell_file)

  c.other += merge_cell.other

  target_cell = os.path.join(target_dir, "%s.cell" % source_name)
  target_param = os.path.join(target_dir, "%s.param" % source_name)
  target_sh = os.path.join(target_dir, "%s.sh" % source_name)

  shutil.copyfile(os.path.join(relax_path, "spectral.param"), target_param)
  shutil.copyfile(os.path.join(relax_path, "spectral.sh"), target_sh)

  cell_out = open(target_cell, "w+")

  print >>cell_out, str(c)

if __name__ == "__main__":
  source_calc = str(sys.argv[1])
  source_dir, source_name = calc_from_path(source_calc)
  target_dir = str(sys.argv[2])

  make(source_dir, source_name, target_dir)

Esempio n. 3
0
    for target_dir, name in runs:
        print >> script, "grep efg %s/%s.magres >> %s-isc.magres" % (
            target_dir, name, root_name)

    os.chmod(script_path, 0755)


if __name__ == "__main__":
    task_name = sys.argv[1]
    source_dir = sys.argv[2]
    target_dir_prefix = sys.argv[3]

    if not os.path.isdir(target_dir_prefix):
        os.mkdir(target_dir_prefix)

    runs = []
    for cell_path in [x for x in os.listdir(source_dir) if ".cell" in x]:
        dir, name = calc_from_path(cell_path)
        run_dir = name
        target_dir = os.path.join(target_dir_prefix, run_dir)

        if not os.path.isdir(target_dir):
            os.mkdir(target_dir)

        task.make_task(task_name, source_dir, name, target_dir)

        runs.append((run_dir, name))

    make_submit_all_script(target_dir_prefix, runs)
    #make_magres_accum_script(target_dir_prefix, name, runs)
Esempio n. 4
0
  for target_dir, name in runs:
    print >>script, "grep efg %s/%s.magres >> %s-isc.magres" % (target_dir, name, root_name)

  os.chmod(script_path, 0755) 

if __name__ == "__main__":
  task_name = sys.argv[1]
  source_dir = sys.argv[2]
  target_dir_prefix = sys.argv[3]

  if not os.path.isdir(target_dir_prefix):
    os.mkdir(target_dir_prefix)

  runs = []
  for cell_path in [x for x in os.listdir(source_dir) if ".cell" in x]:
    dir, name = calc_from_path(cell_path)
    run_dir = name
    target_dir = os.path.join(target_dir_prefix, run_dir)

    if not os.path.isdir(target_dir):
      os.mkdir(target_dir)
    
    task.make_task(task_name, source_dir, name, target_dir)

    runs.append((run_dir, name))

  make_submit_all_script(target_dir_prefix, runs)
  #make_magres_accum_script(target_dir_prefix, name, runs)

Esempio n. 5
0
def make(source,
         target_dir,
         target_name=None,
         num_cores=32,
         queue="parallel.q",
         xc_functional="pbe",
         cut_off_energy=50,
         ncp_pot=False,
         rel_pot=False,
         efg=False,
         c=None,
         **kwargs):

    source_dir, source_name = calc_from_path(source)
    calc = CastepCalc(source_dir, source_name)

    xc_functional = xc_functional.lower()

    if c is None:
        c = cell.Cell(calc.cell_file)

    c.other += merge_cell.other
    c.blocks.update(merge_cell.blocks)

    if ncp_pot:
        if xc_functional == 'pbe':
            _, required_files = pot.add_potentials(settings.NCP_PSPOT_PBE_DIR,
                                                   None, c, rel_pot)
        elif xc_functional == 'lda':
            _, required_files = pot.add_potentials(settings.NCP_PSPOT_LDA_DIR,
                                                   None, c, rel_pot)
        else:
            raise Exception("Cannot use XC functional %s with NCPs" %
                            xc_functional)

        pot.link_files(required_files, target_dir)
    else:
        print rel_pot
        pot.add_potentials_usp(c, rel_pot)

    if target_name is None:
        target_name = source_name

    cell_target = os.path.join(target_dir, "%s.cell" % target_name)
    param_target = os.path.join(target_dir, "%s.param" % target_name)
    sh_target = os.path.join(target_dir, "%s.sh" % target_name)

    sh_context = {
        'seedname': target_name,
        'num_cores': num_cores,
        'h_vmem': float(num_cores) / 8 * 23,
        'queue': queue,
        'CASTEPY_ROOT': settings.CASTEPY_ROOT,
        'USER_EMAIL': settings.USER_EMAIL,
    }

    sh_source = open(os.path.join(nmr_path, "nmr.sh")).read()
    sh_target_file = open(sh_target, "w+")
    param_target_file = open(param_target, "w+")

    params.xc_functional[0] = xc_functional
    params.cut_off_energy[0] = cut_off_energy

    if efg:
        params.magres_task = "efg"
    else:
        params.magres_task = "nmr"

    print >> sh_target_file, sh_source % sh_context
    print >> param_target_file, params

    cell_out = open(cell_target, "w+")

    print >> cell_out, c

    sh_target_file.close()
Esempio n. 6
0
def make(source_dir, source_name, target_dir):
  calc = CastepCalc(source_dir, source_name)

  target_cell = os.path.join(target_dir, "%s.cell" % source_name)
  target_param = os.path.join(target_dir, "%s.param" % source_name)
  target_sh = os.path.join(target_dir, "%s.sh" % source_name)
  
  shutil.copyfile(os.path.join(source_dir, "%s.sh" % source_name), target_sh)

  # Find .DAT files for J-coupling to link, maybe redo this so it uses pot.linkfiles
  for f in os.listdir(source_dir):
    if '.DAT' in f:
      source = os.path.abspath(os.path.join(source_dir, f))
      target = os.path.join(target_dir, f)
      
      if not os.path.isfile(target):
        os.symlink(source, target)

  cell_out = open(target_cell, "w+")
  print >>cell_out, calc.cell_file
  param_out = open(target_param, "w+")
  print >>param_out, calc.param_file

if __name__ == "__main__":
  source_calc = str(sys.argv[1])
  dir, name = calc_from_path(source_calc)
  target_dir = str(sys.argv[2])

  make(dir, name, target_dir)

Esempio n. 7
0
def make(source_dir, source_name, target_dir, relax_species=["H"]):
    calc = calc.CastepCalc(source_dir, source_name)
    calc.load(include=['cell', 'param'])

    if relax_species is None:
        filter = lambda ion: False
    else:
        filter = lambda ion: ion.s not in relax_species

    #c.other += merge_cell.other

    target_cell = os.path.join(target_dir, "%s.cell" % source_name)
    target_param = os.path.join(target_dir, "%s.param" % source_name)
    target_sh = os.path.join(target_dir, "%s.sh" % source_name)

    shutil.copyfile(os.path.join(relax_path, "relax.param"), target_param)
    shutil.copyfile(os.path.join(relax_path, "relax.sh"), target_sh)

    cell_out = open(target_cell, "w+")

    print >> cell_out, str(c)


if __name__ == "__main__":
    source_calc = str(sys.argv[1])
    source_dir, source_name = calc_from_path(source_calc)
    target_dir = str(sys.argv[2])

    make(source_dir, source_name, target_dir)
Esempio n. 8
0
File: nmr.py Progetto: tfgg/castepy
def make(
    source,
    target_dir,
    target_name=None,
    num_cores=32,
    queue="parallel.q",
    xc_functional="pbe",
    cut_off_energy=50,
    ncp_pot=False,
    rel_pot=False,
    efg=False,
    c=None,
    **kwargs
):

    source_dir, source_name = calc_from_path(source)
    calc = CastepCalc(source_dir, source_name)

    xc_functional = xc_functional.lower()

    if c is None:
        c = cell.Cell(calc.cell_file)

    c.other += merge_cell.other
    c.blocks.update(merge_cell.blocks)

    if ncp_pot:
        if xc_functional == "pbe":
            _, required_files = pot.add_potentials(settings.NCP_PSPOT_PBE_DIR, None, c, rel_pot)
        elif xc_functional == "lda":
            _, required_files = pot.add_potentials(settings.NCP_PSPOT_LDA_DIR, None, c, rel_pot)
        else:
            raise Exception("Cannot use XC functional %s with NCPs" % xc_functional)

        pot.link_files(required_files, target_dir)
    else:
        print rel_pot
        pot.add_potentials_usp(c, rel_pot)

    if target_name is None:
        target_name = source_name

    cell_target = os.path.join(target_dir, "%s.cell" % target_name)
    param_target = os.path.join(target_dir, "%s.param" % target_name)
    sh_target = os.path.join(target_dir, "%s.sh" % target_name)

    sh_context = {
        "seedname": target_name,
        "num_cores": num_cores,
        "h_vmem": float(num_cores) / 8 * 23,
        "queue": queue,
        "CASTEPY_ROOT": settings.CASTEPY_ROOT,
        "USER_EMAIL": settings.USER_EMAIL,
    }

    sh_source = open(os.path.join(nmr_path, "nmr.sh")).read()
    sh_target_file = open(sh_target, "w+")
    param_target_file = open(param_target, "w+")

    params.xc_functional[0] = xc_functional
    params.cut_off_energy[0] = cut_off_energy

    if efg:
        params.magres_task = "efg"
    else:
        params.magres_task = "nmr"

    print >> sh_target_file, sh_source % sh_context
    print >> param_target_file, params

    cell_out = open(cell_target, "w+")

    print >> cell_out, c

    sh_target_file.close()