Closed Bernadette-Mohr closed 1 month 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))
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
Added annotations for
hartreedc
andXCdc
.