def standard(entry, **kwargs): """' DEPRECATED: Run a final, static calculation at standard cutoff energy """ if entry.calculations.get("standard", Calculation()).converged: return entry.calculations["standard"] calc = fine_relax(entry, **kwargs) if not calc.converged: calc.write() return calc inp = entry.structures["fine_relax"] if "magnetic" in entry.keywords: inp.set_magnetism("ferro") calc = Calculation.setup( inp, entry=entry, configuration="standard", path=entry.path + "/standard", **kwargs, ) if calc.converged: f = calc.get_formation() f.save() entry.calculations["standard"] = calc entry.structures["standard"] = calc.output ps = PhaseSpace(list(calc.input.comp.keys())) ps.compute_stabilities(save=True) return calc
def standard(entry, **kwargs): '''' DEPRECATED: Run a final, static calculation at standard cutoff energy ''' if entry.calculations.get('standard', Calculation()).converged: return entry.calculations['standard'] calc = fine_relax(entry, **kwargs) if not calc.converged: calc.write() return calc inp = entry.structures['fine_relax'] if 'magnetic' in entry.keywords: inp.set_magnetism('ferro') calc = Calculation.setup(inp, entry=entry, configuration='standard', path=entry.path + '/standard', **kwargs) if calc.converged: f = calc.get_formation() f.save() entry.calculations['standard'] = calc entry.structures['standard'] = calc.output ps = PhaseSpace(calc.input.comp.keys()) ps.compute_stabilities(save=True) return calc
def static(entry, xc_func="PBE", **kwargs): """ Start a final, accurate static calculation Arguments: entry: Entry, structure to be relaxed Keyword Arguments: xc_func: String, name of XC function to use (Default='PBE'). Is used to determine the name of the configuration settings file to use kwargs: Settings passed to calculation object Output: Calculation: results of calculation object """ # Get name of static run and relaxation runs for Co cnfg_name = "static" low_name = "Co_lowspin_static" low_relax_name = "Co_lowspin" high_name = "Co_highspin_static" high_relax_name = "relaxation" if xc_func.lower() != "pbe": cnfg_name += "_%s" % (xc_func.lower()) low_relax_name += "_%s" % (xc_func.lower()) high_relax_name += "_%s" % (xc_func.lower()) low_name += "_%s" % (xc_func.lower()) high_name += "_%s" % (xc_func.lower()) # Get the calculation directory calc_dir = os.path.join(entry.path, cnfg_name) # If static calculation has converged, return that calculation if entry.calculations.get(cnfg_name, Calculation()).converged: return entry.calculations[cnfg_name] # Get the relaxation calculation calc = relaxation(entry, xc_func=xc_func, **kwargs) # Special Case: Check whether relaxation is low-spin if hasattr(calc, "Co_lowspin"): use_lowspin = calc.Co_lowspin is True calc.add_Co_spin("Co_lowspin") else: use_lowspin = False if "Co" in entry.composition: calc.add_Co_spin("Co_highspin") if not calc.converged: return calc # Special case: also perform the static for the higher energy spin configuration if "Co" in entry.comp: # If the lower energy relaxation was high spin, perform now the low spin if not use_lowspin: # Update / start the low spin calculation if (not entry.calculations.get(low_name, Calculation()).converged and entry.calculations.get(low_relax_name, Calculation()).converged): # Get the low_spin calculation directory lowspin_dir = os.path.join(entry.path, low_name) # Get input structure input_struct = entry.calculations[low_relax_name].output calc = Calculation.setup( input_struct, entry=entry, configuration=cnfg_name, path=lowspin_dir, **kwargs, ) # Return atoms to the low-spin configuration for atom in calc.input: if atom.element.symbol == "Co": atom.magmom = 0.01 entry.calculations[low_name] = calc calc.add_Co_spin("Co_lowspin") if not calc.converged: calc.write() else: # Update / start the high spin calculation if (not entry.calculations.get(high_name, Calculation()).converged and entry.calculations.get(high_relax_name, Calculation()).converged): # Get the high_spin calculation directory highspin_dir = os.path.join(entry.path, high_name) # Get input structure input_struct = entry.calculations[high_relax_name].output calc = Calculation.setup( input_struct, entry=entry, configuration=cnfg_name, path=highspin_dir, **kwargs, ) # Return atoms to the high-spin configuration for atom in calc.input: if atom.element.symbol == "Co": atom.magmom = 5 entry.calculations[high_name] = calc calc.add_Co_spin("Co_highspin") if not calc.converged: calc.write() # Input structure == output structure from relaxation in_struct = calc.output # Get path to CHGCAR chgcar_path = calc.path # Set up calculation if "fast" in entry.keywords: calc = Calculation.setup( in_struct, entry=entry, configuration=cnfg_name, path=calc_dir, chgcar=chgcar_path, settings={"kpar": 4}, **kwargs, ) else: calc = Calculation.setup( in_struct, entry=entry, configuration=cnfg_name, path=calc_dir, chgcar=chgcar_path, **kwargs, ) # Special Case: Set Co to low-spin configuration if use_lowspin: for atom in calc.input: if atom.element.symbol == "Co": atom.magmom = 0.01 # Store calculation in Entry list entry.calculations[cnfg_name] = calc # Save calculation [ LW 20Jan16: Only for PBE for now ] if calc.converged and xc_func.lower() == "pbe": calc.save() f = calc.get_formation( ) # LW 16 Jan 2016: Need to rewrite this to have # separate hulls for LDA / PBE / ... f.save() ps = PhaseSpace(list(calc.input.comp.keys())) ps.compute_stabilities(reevaluate=True, save=True) else: calc.write() return calc
def static(entry, xc_func='PBE', **kwargs): ''' Start a final, accurate static calculation Arguments: entry: Entry, structure to be relaxed Keyword Arguments: xc_func: String, name of XC function to use (Default='PBE'). Is used to determine the name of the configuration settings file to use kwargs: Settings passed to calculation object Output: Calculation: results of calculation object ''' # Get name of static run cnfg_name = 'static' if xc_func.lower() != 'pbe': cnfg_name += "_%s" % (xc_func.lower()) # Get the calculation directory calc_dir = os.path.join(entry.path, cnfg_name) # Check if this calculation has converged if entry.calculations.get(cnfg_name, Calculation()).converged: return entry.calculations[cnfg_name] # Get the relaxation calculation calc = relaxation(entry, xc_func=xc_func, **kwargs) # Special Case: Check whether relaxation is low-spin if hasattr(calc, 'Co_lowspin'): use_lowspin = (calc.Co_lowspin is True) else: use_lowspin = False if not calc.converged: return calc # Input structure == output structure from relaxation input = calc.output # Get path to CHGCAR chgcar_path = calc.path # Set up calculation calc = Calculation.setup(input, entry=entry, configuration=cnfg_name, path=calc_dir, chgcar=chgcar_path, **kwargs) # Special Case: Set Co to low-spin configuration if use_lowspin: for atom in calc.input: if atom.element.symbol == 'Co': atom.magmom = 0.01 # Store calculation in Entry list entry.calculations[cnfg_name] = calc # Save calculation [ LW 20Jan16: Only for PBE for now ] if calc.converged and xc_func.lower() == 'pbe': f = calc.get_formation( ) # LW 16 Jan 2016: Need to rewrite this to have # separate hulls for LDA / PBE / ... f.save() ps = PhaseSpace(calc.input.comp.keys()) ps.compute_stabilities(reevaluate=True, save=True) else: calc.write() return calc
def static(entry, xc_func='PBE', **kwargs): ''' Start a final, accurate static calculation Arguments: entry: Entry, structure to be relaxed Keyword Arguments: xc_func: String, name of XC function to use (Default='PBE'). Is used to determine the name of the configuration settings file to use kwargs: Settings passed to calculation object Output: Calculation: results of calculation object ''' # Get name of static run cnfg_name = 'static' if xc_func.lower() != 'pbe': cnfg_name += "_%s"%(xc_func.lower()) # Get the calculation directory calc_dir = os.path.join(entry.path, cnfg_name) # Check if this calculation has converged if entry.calculations.get(cnfg_name, Calculation()).converged: return entry.calculations[cnfg_name] # Get the relaxation calculation calc = relaxation(entry, xc_func=xc_func, **kwargs) # Special Case: Check whether relaxation is low-spin if hasattr(calc, 'Co_lowspin'): use_lowspin = ( calc.Co_lowspin is True ) else: use_lowspin = False if not calc.converged: return calc # Input structure == output structure from relaxation in_struct = calc.output # Get path to CHGCAR chgcar_path = calc.path # Set up calculation calc = Calculation.setup(in_struct, entry=entry, configuration=cnfg_name, path=calc_dir, chgcar=chgcar_path, **kwargs) # Special Case: Set Co to low-spin configuration if use_lowspin: for atom in calc.input: if atom.element.symbol == 'Co': atom.magmom = 0.01 # Store calculation in Entry list entry.calculations[cnfg_name] = calc # Save calculation [ LW 20Jan16: Only for PBE for now ] if calc.converged and xc_func.lower() == 'pbe': f = calc.get_formation() # LW 16 Jan 2016: Need to rewrite this to have # separate hulls for LDA / PBE / ... calc.save() f.calculation = calc f.save() ps = PhaseSpace(calc.input.comp.keys()) for p in ps.phases: if p in ps.phase_dict.values(): ps.compute_stability(p) else: p2 = ps.phase_dict[p.name] ps.compute_stability(p2) base = max(0, p2.stability) diff = p.energy - p2.energy p.stability = base + diff temp_c = Calculation.objects.get(formationenergy__id=p.id) if temp_c.id == calc.id: print("new calc stability") f.stability = p.stability f.save() else: try: fe = temp_c.get_formation() except MultipleObjectsReturned: print("Calculation ", temp_c.id, " has more than one formationenergy") continue if fe is None: continue fe.stability = p.stability fe.save() #ps.compute_stabilities(reevaluate=True, save=True) else: calc.write() return calc