Example #1
0
def run_eos_wf(codename, pseudo_family, element):
    print "Workfunction node identifiers: {}".format(Process.current().calc)
    s0 = create_diamond_fcc(Str(element))

    calcs = {}
    for label, factor in zip(labels, scale_facs):
        s = rescale(s0, Float(factor))
        inputs = generate_scf_input_params(s, str(codename),
                                           Str(pseudo_family))
        print "Running a scf for {} with scale factor {}".format(
            element, factor)
        result = run(PwCalculation, **inputs)
        print "RESULT: {}".format(result)
        calcs[label] = get_info(result)

    eos = []
    for label in labels:
        eos.append(calcs[label])

    # Return information to plot the EOS
    ParameterData = DataFactory('parameter')
    retdict = {
        'initial_structure': s0,
        'result': ParameterData(dict={'eos_data': eos})
    }

    return retdict
def get_structure(original_structure, new_volume):
    """
    Given a structure and a new volume, rescale the structure to the new volume
    """
    initial_volume = original_structure.get_cell_volume()
    scale_factor = (new_volume/initial_volume)**(1./3.)        
    scaled_structure = rescale(original_structure, Float(scale_factor))
    return scaled_structure
def get_structure(original_structure, new_volume):
    """
    Given a structure and a new volume, rescale the structure to the new volume
    """
    initial_volume = original_structure.get_cell_volume()
    scale_factor = (new_volume / initial_volume)**(1. / 3.)
    scaled_structure = rescale(original_structure, Float(scale_factor))
    return scaled_structure
def get_structure(structure, step_data=None):
    """Return a scaled version of the given structure, where the new volume is determined by the given step data."""
    initial_volume = structure.get_cell_volume()

    if step_data is None:
        new_volume = initial_volume + 4.  # In Å^3
    else:
        # Minimum of a parabola
        new_volume = -step_data.dict.b / 2. / step_data.dict.a

    scale_factor = (new_volume / initial_volume)**(1. / 3.)
    scaled_structure = rescale(structure, Float(scale_factor))
    return scaled_structure
Example #5
0
def run_eos_wf(codename, pseudo_family, element):
	print "Workfunction node pk: {}".format(registry.current_calc_node)
	#Instantiate a JobCalc process and create basic structure
	JobCalc = PwCalculation.process()
	s0 = create_diamond_fcc(Str(element))
	eos=[]
	scale_facs = (0.98, 0.99, 1.0, 1.02, 1.04)
	for factor in  scale_facs:
		s = rescale(s0,Float(factor))
		inputs = generate_scf_input_params(
			s, str(codename), str(pseudo_family))
		print "Running a scf for {} with scale factor {}".format(
			element, factor)
	calc_results = run(JobCalc,**inputs)
	eos.append(get_info(calc_results))
	#Return information to plot the EOS
	ParameterData = DataFactory("parameter")
	return {'initial_structure': s0,'result': ParameterData(dict={'eos_data': eos})}
Example #6
0
    def run_pw(self):
        print "Workchain node identifiers: {}".format(self.calc)
        #Instantiate a JobCalc process and create basic structure
        JobCalc = PwCalculation.process()
        self.ctx.s0 = create_diamond_fcc(Str(self.inputs.element))
        self.ctx.eos_names = []

        calcs = {}
        for label, factor in zip(labels, scale_facs):
            s = rescale(self.ctx.s0, Float(factor))
            inputs = generate_scf_input_params(s, str(self.inputs.code),
                                               self.inputs.pseudo_family)
            print "Running a scf for {} with scale factor {}".format(
                self.inputs.element, factor)
            future = submit(JobCalc, **inputs)
            calcs[label] = future

        # Ask the workflow to continue when the results are ready and store them
        # in the context
        return ToContext(**calcs)
def run_eos_wf(code, pseudo_family, element):
    """Run an equation of state of a bulk crystal structure for the given element."""

    # This will print the pk of the work function
    print('Running run_eos_wf<{}>'.format(Process.current().pid))

    scale_factors = (0.96, 0.98, 1.0, 1.02, 1.04)
    labels = ['c1', 'c2', 'c3', 'c4', 'c5']

    calculations = {}

    # Create an initial bulk crystal structure for the given element, using the calculation function defined earlier
    initial_structure = create_diamond_fcc(element)

    # Loop over the label and scale_factor pairs
    for label, factor in list(zip(labels, scale_factors)):

        # Generated the scaled structure from the initial structure
        structure = rescale(initial_structure, Float(factor))

        # Generate the inputs for the `PwCalculation`
        inputs = generate_scf_input_params(structure, code, pseudo_family)

        # Launch a `PwCalculation` for each scaled structure
        print('Running a scf for {} with scale factor {}'.format(
            element, factor))
        calculations[label] = run(PwCalculation, **inputs)

    # Bundle the individual results from each `PwCalculation` in a single dictionary node.
    # Note: since we are 'creating' new data from existing data, we *have* to go through a `calcfunction`, otherwise
    # the provenance would be lost!
    inputs = {
        label: result['output_parameters']
        for label, result in calculations.items()
    }
    eos = create_eos_dictionary(**inputs)

    # Finally, return the results of this work function
    result = {'initial_structure': initial_structure, 'eos': eos}

    return result
    def run_eos(self):
        """Run calculations for equation of state."""
        # Create basic structure and attach it as an output
        initial_structure = create_diamond_fcc(self.inputs.element)
        self.out('initial_structure', initial_structure)

        calculations = {}

        for label, factor in zip(labels, scale_facs):

            structure = rescale(initial_structure, Float(factor))
            inputs = generate_scf_input_params(structure, self.inputs.code,
                                               self.inputs.pseudo_family)

            self.report(
                'Running an SCF calculation for {} with scale factor {}'.
                format(self.inputs.element, factor))
            future = self.submit(PwCalculation, **inputs)
            calculations[label] = future

        # Ask the workflow to continue when the results are ready and store them in the context
        return ToContext(**calculations)
    def run_pw(self, ctx):
        
        PwProcess = PwCalculation.process()
        ctx.s0 = create_diamond_fcc(Str(self.inputs.element))

        ctx.eos_names = []
        calcs = {}
 
        for label, factor in zip(labels, scale_facs):
            s = rescale(ctx.s0,Float(factor))
            inputs = generate_scf_input_params(
                s, str(self.inputs.code), str(self.inputs.pseudo_family))
            print "Running a scf for {} with scale factor {}".format(
                self.inputs.element, factor)

            # Launch the code
            future = self.submit(PwProcess, inputs)
            # Store the future
            calcs[label] = future
          
        # Ask the workflow to continue when the results are ready and store them
        # in the context
        return ResultToContext(**calcs)