from ...potential_definitions import PotSectionDefinition, PotValueDefinition
from ...potential_sections import PotentialSection as PotSection, AtomicTypePotentialSection
from ....common.grammar_types import NumpyArray, RawData
from ....common.configuration_definitions import SeparatorDefinition, BaseDefinition
import re
[docs]
def _sections_potential_fullpot_condition(value):
return value != ""
[docs]
def _sections_potential_fullpot_write_condition(value):
return value() != ""
[docs]
class PotentialSection(PotSection):
pass
[docs]
class PotentialsSection(AtomicTypePotentialSection):
property_name = "potential"
property_label = "radial potential"
[docs]
class PotentialSectionDefinition(PotSectionDefinition):
[docs]
def __init__(self, name="POTENTIAL", **kwargs):
V = PotValueDefinition
members = [
V("TYPE", int),
V(
"DATA",
NumpyArray(
line_length=100,
shape=(2, -1),
ends_with=re.compile("\n?(={79}|-{79}|NFP)"),
item_format="% .14E",
indented=1,
),
name_in_grammar=False,
),
V(
"FULLPOT",
RawData(ends_with=re.compile("\n?(={79}|-{79})"), condition=_sections_potential_fullpot_condition),
is_required=False,
name_in_grammar=False,
write_condition=_sections_potential_fullpot_write_condition,
),
SeparatorDefinition("=", length=79),
]
super().__init__(
name, members, has_hidden_members=True, is_repeated=BaseDefinition.Repeated.LIST_SECTION, is_optional=True
)
result_class = PotentialSection
repeated_class = PotentialsSection
section = PotentialSectionDefinition