def from_configuration_dir(cls, configuration_dir, calctype, auto=True, sort=True): """returns a instance of the Neb class instantited with a single configuration""" # change config_dir to configuration_dir all over proj = Project(configuration_dir) sel = Selection(proj, "EMPTY", "config", False) split_path = configuration_dir.split(os.path.sep) index = split_path.index("training_data") name = '/'.join(split_path[index + 1:]) sel.data = pandas.DataFrame({ "name": name, "selected": 1 }, index=range(1)) # try: # os.mkdir(os.path.join(proj.path, ".casm/tmp")) # except: # pass # sel_config = sel.saveas(os.path.join(proj.path, ".casm/tmp", configname.replace('/', '.')), True) obj = cls(sel, calctype, auto, sort) return obj
"tolerance" : 0.001 }, "incremental_conditions" : { "param_chem_pot" : { "a" : 0.0 }, "temperature" : -100.0, "tolerance" : 0.001 } } with open('../example_grand_canonical/metropolis_grand_canonical.json','r') as f: input = json.load(f) cwd = os.getcwd() proj = Project() index = 0 for xi in np.arange(-3.,0.,0.1): path = 'path.' + str(index) tinput = copy.deepcopy(input) tinput['driver'] = d tinput['driver']['initial_conditions']['param_chem_pot']['a'] = xi tinput['driver']['final_conditions']['param_chem_pot']['a'] = xi os.mkdir(path) os.chdir(path) with open('input.json','w') as f: json.dump(tinput, f)
# attributes to hall[indiv_i]: # # "dft_gs" : DFT calculated ground states # "clex_gs" : predicted ground states # "gs_missing" : DFT ground states that are not predicted ground states # "gs_spurious" : Predicted ground states that are not DFT ground states # "uncalculated" : Predicted ground states and near ground states that have not been calculated # "below_hull" : All configurations predicted below the prediction of the DFT hull # "ranged_rms": root-mean-square error calculated for the subset of configurations # whose DFT formation energy lies within some range of the DFT convex hull. # Currently calculated for ranges 0.001, 0.005, 0.01, 0.05, 0.1, 0.5 eV/unit cell # indiv_i = 0 checkhull(input, hall, indices=[indiv_i]) proj = Project() # make sure ECI are saved into CASM project indiv = hall[indiv_i] write_eci(proj, hall[0].eci, to_json(indiv_i, hall[indiv_i])) ### Get data for plotting # query properties from CASM sel = Selection(proj, selection, all=False) comp_a = 'comp(a)' is_calculated = 'is_calculated' dft_Ef = 'formation_energy' clex_Ef = 'clex(formation_energy)' sel.query([comp_a, is_calculated, dft_Ef, clex_Ef])
def main(argv = None): if argv is None: argv = sys.argv[1:] parser = argparse.ArgumentParser(description = 'Submit calculations for CASM') parser.add_argument('-c', '--configs', help=configs_help, type=str, default="MASTER") parser.add_argument('--path', help=path_help, type=str, default=None) parser.add_argument('-m','--method', help=method_help, type=str, default=None) parser.add_argument('--run', help=run_help, action="store_true", default=False) parser.add_argument('--submit', help=submit_help, action="store_true", default=False) parser.add_argument('--setup', help=setup_help, action="store_true", default=False) parser.add_argument('--report', help=report_help, action="store_true", default=False) args = parser.parse_args(argv) if args.path is None: args.path = getcwd() try: proj = Project(abspath(args.path)) sel = Selection(proj, args.configs, all=False) if sel.data["configname"] is not None: configname=sel.data["configname"][0] casm_settings=proj.settings if casm_settings == None: raise casm.qewrapper.QEWrapperError("Not in a CASM project. The file '.casm' directory was not found.") casm_directories=proj.dir print(" Reading relax.json settings file") sys.stdout.flush() setfile = casm_directories.settings_path_crawl("relax.json",configname,casm_settings.default_clex) if setfile == None: raise casm.qewrapper.QEWrapperError("Could not find \"relax.json\" in an appropriate \"settings\" directory") sys.stdout.flush() else: print("Using "+str(setfile)+" as settings...") settings = casm.qewrapper.read_settings(setfile) if settings["software"] is None: settings["software"]="vasp" software=settings["software"] print("Relevant software is:", software) if args.setup: sel.write_pos() for configname in sel.data["configname"]: if software == "quantumespresso": relaxation = casm.qewrapper.Relax(proj.dir.configuration_dir(configname)) elif software == "lammps": relaxation = casm.lammpswrapper.Relax(proj.dir.configuration_dir(configname)) else: relaxation = Relax(proj.dir.configuration_dir(configname)) relaxation.setup() elif args.submit: sel.write_pos() for configname in sel.data["configname"]: if software == "quantumespresso": relaxation = casm.qewrapper.Relax(proj.dir.configuration_dir(configname)) elif software == "lammps": relaxation = casm.lammpswrapper.Relax(proj.dir.configuration_dir(configname)) else: relaxation = Relax(proj.dir.configuration_dir(configname)) relaxation.submit() elif args.run: sel.write_pos() for configname in sel.data["configname"]: if software == "quantumespresso": relaxation = casm.qewrapper.Relax(proj.dir.configuration_dir(configname)) elif software == "lammps": relaxation = casm.lammpswrapper.Relax(proj.dir.configuration_dir(configname)) else: relaxation = Relax(proj.dir.configuration_dir(configname)) relaxation.run() elif args.report: for configname in sel.data["configname"]: configdir = proj.dir.configuration_dir(configname) clex = proj.settings.default_clex calcdir = proj.dir.calctype_dir(configname, clex) finaldir = join(calcdir, "run.final") try: if software == "quantumespresso": if settings["outfilename"] is None: print("WARNING: No output file specified in relax.json using default outfilename of std.out") settings["outfilename"]="std.out" outfilename = settings["outfilename"] output = casm.qewrapper.Relax.properties(finaldir,outfilename) elif software == "lammps": output = casm.lammpswrapper.Relax.properties(calcdir) else: output = Relax.properties(finaldir) calc_props = proj.dir.calculated_properties(configname, clex) print("writing:", calc_props) with open(calc_props, 'wb') as f: f.write(six.u(json.dumps(output, cls=noindent.NoIndentEncoder, indent=2)).encode('utf-8')) #compat.dump(json, output, calc_props, 'w', cls=noindent.NoIndentEncoder, indent=4, sort_keys=True) except: print(("Unable to report properties for directory {}.\n" "Please verify that it contains a completed calculation.".format(configdir))) except Exception as e: print(e) sys.exit(1)
def main(argv=None): if argv is None: argv = sys.argv[1:] parser = argparse.ArgumentParser( description='Submit calculations for CASM') parser.add_argument('-c', '--configs', help=configs_help, type=str, default="MASTER") parser.add_argument('-t', '--type', help=configtype_help, type=str, default="config") parser.add_argument('--calctype', help=calctype_help, type=str, default="") parser.add_argument('--path', help=path_help, type=str, default=None) parser.add_argument('--run', help=run_help, action="store_true", default=False) parser.add_argument('--submit', help=submit_help, action="store_true", default=False) parser.add_argument('--setup', help=setup_help, action="store_true", default=False) parser.add_argument('--report', help=report_help, action="store_true", default=False) args = parser.parse_args(argv) if args.path is None: args.path = getcwd() try: proj = Project(abspath(args.path)) sel = Selection(proj, args.configs, args.type, all=False) if args.calctype == "": #get default calctype args.calctype = proj.settings.default_clex.calctype global_settings = json.load( open( join(proj.dir.calctype_settings_dir(args.calctype), "calc.json"))) software = global_settings["software"] method = global_settings["method"] # Construct with Selection: # - This provides access to the Project, via sel.proj # - From the project you can make calls to run interpolation and query lattice relaxations calculator = available_calculators[software][method](sel, args.calctype) if args.setup: calculator.setup() elif args.submit: calculator.submit() elif args.run: calculator.run() elif args.report: calculator.report() except Exception as e: print(e) sys.exit(1)
}, "incremental_conditions": { "param_chem_pot": { "a": 0.0 }, "temperature": -100.0, "tolerance": 0.001 } } with open('../example_grand_canonical/metropolis_grand_canonical.json', 'r') as f: input = json.load(f) cwd = os.getcwd() proj = Project() index = 0 for xi in np.arange(-3., 0., 0.1): path = 'path.' + str(index) tinput = copy.deepcopy(input) tinput['driver'] = d tinput['driver']['initial_conditions']['param_chem_pot']['a'] = xi tinput['driver']['final_conditions']['param_chem_pot']['a'] = xi os.mkdir(path) os.chdir(path) with open('input.json', 'w') as f: json.dump(tinput, f)
def monte_cmd(input): global proj if proj is None: proj = Project() stdout, stderr, returncode = proj.command('monte -s input.json') print stdout