FAIRmat-NFDI / nomad-parser-vasp

NOMAD parser plugin for VASP input/output files.
Apache License 2.0
2 stars 1 forks source link

tutorial_DcEnergies #5

Closed Bernadette-Mohr closed 1 month ago

Bernadette-Mohr commented 4 months ago

Added annotations for hartreedc and XCdc.

JFRudzinski commented 4 months ago

@Bernadette-Mohr I think the code in the parser should look something like this:

total_energy = xml_get(<path to total energy>)
hartreedc = xml_get(<path to hartreedc energy>)
xcdc = xml_get(<path to xcdc energy>)

simulation = Simulation()
output = Outputs()
simulation.outputs.append(output)
output.total_energy.append(TotalEnergy())

output.total_energy[0].contributions.append(HartreeDCEnergy(value=total_energy * ureg.eV))
output.total_energy[0].contributions.append(XCdcEnergy(value=total_energy * ureg.eV))
JFRudzinski commented 4 months ago

Ok, here is some draft for the schema:

class DoubleCountingEnergy(BaseEnergy):
    value = Quantity(
        type=np.dtype(np.float64),
        unit='eV',
    )

    type = Quantity(
        type=MEnum('double_counting'),
    )

    def normalize(self, archive: 'EntryArchive', logger: 'BoundLogger') -> None:
        super().normalize(archive, logger)

        if not self.type:
            self.type = 'double_counting'

class HartreeDCEnergy(DoubleCountingEnergy):

    def normalize(self, archive: 'EntryArchive', logger: 'BoundLogger') -> None:
        super().normalize(archive, logger)

class XCdcEnergy(DoubleCountingEnergy):

    def normalize(self, archive: 'EntryArchive', logger: 'BoundLogger') -> None:
        super().normalize(archive, logger)

class RestEnergy(BaseEnergy):

    def normalize(self, archive: 'EntryArchive', logger: 'BoundLogger') -> None:
        super().normalize(archive, logger)

class TotalEnergy(nomad_simulations.schema_packages.properties.TotalEnergy):

    def normalize(self, archive: 'EntryArchive', logger: 'BoundLogger') -> None:
        super().normalize(archive, logger)

        if self.total_energy:
            for total_energy in self.total_energy:
                if total_energy.value and total_energy.contributions:
                    value = total_energy.value
                    for contribution in total_energy.contributions:
                        value -= contribution.value
                    total_energy.rest_energy.append(RestEnergy(value=value))

I would be shocked if it works without adjustments but I hope it gives you an idea, let me know if clarifications are needed or you have problems