Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

tutorial_DcEnergies #5

Closed
wants to merge 5 commits into from
Closed

Conversation

Bernadette-Mohr
Copy link
Collaborator

Added annotations for hartreedc and XCdc.

@JFRudzinski
Copy link
Collaborator

@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
Copy link
Collaborator

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

@ndaelman-hu ndaelman-hu deleted the tutorial_DcEnergies branch September 26, 2024 16:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants