Skip to content

Commit 5580d69

Browse files
committed
- Remove superfluous use of naming logic & initializers
- Add naming logic to `Variables` base section
1 parent 0f76e62 commit 5580d69

File tree

8 files changed

+11
-137
lines changed

8 files changed

+11
-137
lines changed

src/nomad_simulations/schema_packages/properties/band_gap.py

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -57,11 +57,6 @@ class ElectronicBandGap(PhysicalProperty):
5757
""",
5858
)
5959

60-
def __init__(
61-
self, m_def: 'Section' = None, m_context: 'Context' = None, **kwargs
62-
) -> None:
63-
super().__init__(m_def, m_context, **kwargs)
64-
self.name = self.m_def.name
6560

6661
def resolve_type(self, logger: 'BoundLogger') -> Optional[str]:
6762
"""

src/nomad_simulations/schema_packages/properties/fermi_surface.py

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -28,12 +28,6 @@ class FermiSurface(PhysicalProperty):
2828
""",
2929
)
3030

31-
def __init__(
32-
self, m_def: 'Section' = None, m_context: 'Context' = None, **kwargs
33-
) -> None:
34-
super().__init__(m_def, m_context, **kwargs)
35-
# ! `n_bands` need to be set up during initialization of the class
36-
self.name = self.m_def.name
3731

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

src/nomad_simulations/schema_packages/properties/greens_function.py

Lines changed: 0 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -189,11 +189,6 @@ class ElectronicGreensFunction(BaseGreensFunction):
189189
""",
190190
)
191191

192-
def __init__(
193-
self, m_def: 'Section' = None, m_context: 'Context' = None, **kwargs
194-
) -> None:
195-
super().__init__(m_def, m_context, **kwargs)
196-
self.name = self.m_def.name
197192

198193

199194
class ElectronicSelfEnergy(BaseGreensFunction):
@@ -211,11 +206,6 @@ class ElectronicSelfEnergy(BaseGreensFunction):
211206
""",
212207
)
213208

214-
def __init__(
215-
self, m_def: 'Section' = None, m_context: 'Context' = None, **kwargs
216-
) -> None:
217-
super().__init__(m_def, m_context, **kwargs)
218-
self.name = self.m_def.name
219209

220210

221211
class HybridizationFunction(BaseGreensFunction):
@@ -233,11 +223,6 @@ class HybridizationFunction(BaseGreensFunction):
233223
""",
234224
)
235225

236-
def __init__(
237-
self, m_def: 'Section' = None, m_context: 'Context' = None, **kwargs
238-
) -> None:
239-
super().__init__(m_def, m_context, **kwargs)
240-
self.name = self.m_def.name
241226

242227

243228
class QuasiparticleWeight(PhysicalProperty):
@@ -320,11 +305,6 @@ class QuasiparticleWeight(PhysicalProperty):
320305
""",
321306
)
322307

323-
def __init__(
324-
self, m_def: 'Section' = None, m_context: 'Context' = None, **kwargs
325-
) -> None:
326-
super().__init__(m_def, m_context, **kwargs)
327-
self.name = self.m_def.name
328308

329309
def resolve_system_correlation_strengths(self) -> str:
330310
"""

src/nomad_simulations/schema_packages/properties/hopping_matrix.py

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -43,11 +43,6 @@ class HoppingMatrix(PhysicalProperty):
4343
""",
4444
)
4545

46-
def __init__(
47-
self, m_def: 'Section' = None, m_context: 'Context' = None, **kwargs
48-
) -> None:
49-
super().__init__(m_def, m_context, **kwargs)
50-
self.name = self.m_def.name
5146

5247
# TODO add normalization to extract DOS, band structure, etc, properties from `HoppingMatrix`
5348

@@ -76,8 +71,3 @@ class CrystalFieldSplitting(PhysicalProperty):
7671
""",
7772
)
7873

79-
def __init__(
80-
self, m_def: 'Section' = None, m_context: 'Context' = None, **kwargs
81-
) -> None:
82-
super().__init__(m_def, m_context, **kwargs)
83-
self.name = self.m_def.name

src/nomad_simulations/schema_packages/properties/permittivity.py

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,10 @@ class Permittivity(PhysicalProperty):
2525
"""
2626

2727
iri = 'http://fairmat-nfdi.eu/taxonomy/Permittivity'
28+
29+
# Class-level constants
30+
rank = [3, 3]
31+
_axes_map = ['xx', 'yy', 'zz']
2832

2933
type = Quantity(
3034
type=MEnum('static', 'dynamic'),
@@ -51,13 +55,6 @@ class Permittivity(PhysicalProperty):
5155
# ? We need use cases to understand if we need to define contributions to the permittivity tensor.
5256
# ? `ionic` and `electronic` contributions are common in the literature.
5357

54-
def __init__(
55-
self, m_def: 'Section' = None, m_context: 'Context' = None, **kwargs
56-
) -> None:
57-
super().__init__(m_def, m_context, **kwargs)
58-
self.rank = [3, 3]
59-
self.name = self.m_def.name
60-
self._axes_map = ['xx', 'yy', 'zz']
6158

6259
def resolve_type(self) -> str:
6360
return 'static' if self.frequencies is None else 'dynamic'

src/nomad_simulations/schema_packages/properties/spectral_profile.py

Lines changed: 0 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -65,11 +65,6 @@ class DOSProfile(SpectralProfile):
6565
""",
6666
)
6767

68-
def __init__(
69-
self, m_def: 'Section' = None, m_context: 'Context' = None, **kwargs
70-
) -> None:
71-
super().__init__(m_def, m_context, **kwargs)
72-
7368
def resolve_pdos_name(self, logger: 'BoundLogger') -> Optional[str]:
7469
"""
7570
Resolve the `name` of the projected `DOSProfile` from the `entity_ref` section. This is resolved as:
@@ -191,12 +186,6 @@ class ElectronicDensityOfStates(DOSProfile):
191186
""",
192187
)
193188

194-
def __init__(
195-
self, m_def: 'Section' = None, m_context: 'Context' = None, **kwargs
196-
) -> None:
197-
super().__init__(m_def, m_context, **kwargs)
198-
self.name = self.m_def.name
199-
200189
def resolve_energies_origin(
201190
self,
202191
energies_points: pint.Quantity,
@@ -506,13 +495,6 @@ class AbsorptionSpectrum(SpectralProfile):
506495
""",
507496
)
508497

509-
def __init__(
510-
self, m_def: 'Section' = None, m_context: 'Context' = None, **kwargs
511-
) -> None:
512-
super().__init__(m_def, m_context, **kwargs)
513-
# Set the name of the section
514-
self.name = self.m_def.name
515-
516498

517499
class XASSpectrum(AbsorptionSpectrum):
518500
"""
@@ -535,13 +517,6 @@ class XASSpectrum(AbsorptionSpectrum):
535517
repeats=False,
536518
)
537519

538-
def __init__(
539-
self, m_def: 'Section' = None, m_context: 'Context' = None, **kwargs
540-
) -> None:
541-
super().__init__(m_def, m_context, **kwargs)
542-
# Set the name of the section
543-
self.name = self.m_def.name
544-
545520
def generate_from_contributions(self, logger: 'BoundLogger') -> None:
546521
"""
547522
Generate the `value` of the XAS spectrum by concatenating the XANES and EXAFS contributions. It also concatenates

src/nomad_simulations/schema_packages/properties/thermodynamics.py

Lines changed: 4 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -134,11 +134,6 @@ class ChemicalPotential(BaseEnergy):
134134

135135
iri = 'http://fairmat-nfdi.eu/taxonomy/ChemicalPotential'
136136

137-
def __init__(
138-
self, m_def: 'Section' = None, m_context: 'Context' = None, **kwargs
139-
) -> None:
140-
super().__init__(m_def, m_context, **kwargs)
141-
self.name = self.m_def.name
142137

143138

144139
class HeatCapacity(PhysicalProperty):
@@ -167,13 +162,8 @@ class VirialTensor(BaseEnergy):
167162
The `VirialTensor` can be related to the non-ideal pressure of the system through
168163
the virial theorem.
169164
"""
170-
171-
def __init__(
172-
self, m_def: 'Section' = None, m_context: 'Context' = None, **kwargs
173-
) -> None:
174-
super().__init__(m_def, m_context, **kwargs)
175-
self.rank = [3, 3]
176-
self.name = self.m_def.name
165+
166+
rank = [3, 3]
177167

178168

179169
class MassDensity(PhysicalProperty):
@@ -195,17 +185,12 @@ class Hessian(PhysicalProperty):
195185
A square matrix of second-order partial derivatives of a potential energy function,
196186
describing the local curvature of the energy surface.
197187
"""
188+
189+
rank = [3, 3]
198190

199191
value = Quantity(
200192
type=np.float64,
201193
unit='joule / m ** 2',
202194
description="""
203195
""",
204196
)
205-
206-
def __init__(
207-
self, m_def: 'Section' = None, m_context: 'Context' = None, **kwargs
208-
) -> None:
209-
super().__init__(m_def, m_context, **kwargs)
210-
self.rank = [3, 3]
211-
self.name = self.m_def.name

src/nomad_simulations/schema_packages/variables.py

Lines changed: 3 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,9 @@ def normalize(self, archive: 'EntryArchive', logger: 'BoundLogger') -> None:
7575
# Setting `n_points` if these are not defined
7676
self.n_points = self.get_n_points(logger)
7777

78+
if self.m_def.name is not None:
79+
self.name = self.m_def.name
80+
7881

7982
class Temperature(Variables):
8083
""" """
@@ -88,11 +91,6 @@ class Temperature(Variables):
8891
""",
8992
)
9093

91-
def __init__(
92-
self, m_def: 'Section' = None, m_context: 'Context' = None, **kwargs
93-
) -> None:
94-
super().__init__(m_def, m_context, **kwargs)
95-
self.name = self.m_def.name
9694

9795
def normalize(self, archive: 'EntryArchive', logger: 'BoundLogger') -> None:
9896
super().normalize(archive, logger)
@@ -111,11 +109,6 @@ class Energy2(Variables):
111109
""",
112110
)
113111

114-
def __init__(
115-
self, m_def: 'Section' = None, m_context: 'Context' = None, **kwargs
116-
) -> None:
117-
super().__init__(m_def, m_context, **kwargs)
118-
self.name = self.m_def.name
119112

120113
def normalize(self, archive: 'EntryArchive', logger: 'BoundLogger') -> None:
121114
super().normalize(archive, logger)
@@ -135,11 +128,6 @@ class WignerSeitz(Variables):
135128
""",
136129
)
137130

138-
def __init__(
139-
self, m_def: 'Section' = None, m_context: 'Context' = None, **kwargs
140-
) -> None:
141-
super().__init__(m_def, m_context, **kwargs)
142-
self.name = self.m_def.name
143131

144132
def normalize(self, archive: 'EntryArchive', logger: 'BoundLogger') -> None:
145133
super().normalize(archive, logger)
@@ -157,11 +145,6 @@ class Frequency(Variables):
157145
""",
158146
)
159147

160-
def __init__(
161-
self, m_def: 'Section' = None, m_context: 'Context' = None, **kwargs
162-
) -> None:
163-
super().__init__(m_def, m_context, **kwargs)
164-
self.name = self.m_def.name
165148

166149
def normalize(self, archive: 'EntryArchive', logger: 'BoundLogger') -> None:
167150
super().normalize(archive, logger)
@@ -179,11 +162,6 @@ class MatsubaraFrequency(Variables):
179162
""",
180163
)
181164

182-
def __init__(
183-
self, m_def: 'Section' = None, m_context: 'Context' = None, **kwargs
184-
) -> None:
185-
super().__init__(m_def, m_context, **kwargs)
186-
self.name = self.m_def.name
187165

188166
def normalize(self, archive: 'EntryArchive', logger: 'BoundLogger') -> None:
189167
super().normalize(archive, logger)
@@ -201,11 +179,6 @@ class Time(Variables):
201179
""",
202180
)
203181

204-
def __init__(
205-
self, m_def: 'Section' = None, m_context: 'Context' = None, **kwargs
206-
) -> None:
207-
super().__init__(m_def, m_context, **kwargs)
208-
self.name = self.m_def.name
209182

210183
def normalize(self, archive: 'EntryArchive', logger: 'BoundLogger') -> None:
211184
super().normalize(archive, logger)
@@ -223,11 +196,6 @@ class ImaginaryTime(Variables):
223196
""",
224197
)
225198

226-
def __init__(
227-
self, m_def: 'Section' = None, m_context: 'Context' = None, **kwargs
228-
) -> None:
229-
super().__init__(m_def, m_context, **kwargs)
230-
self.name = self.m_def.name
231199

232200
def normalize(self, archive: 'EntryArchive', logger: 'BoundLogger') -> None:
233201
super().normalize(archive, logger)
@@ -246,11 +214,6 @@ class KMesh(Variables):
246214
""",
247215
)
248216

249-
def __init__(
250-
self, m_def: 'Section' = None, m_context: 'Context' = None, **kwargs
251-
) -> None:
252-
super().__init__(m_def, m_context, **kwargs)
253-
self.name = self.m_def.name
254217

255218
def normalize(self, archive: 'EntryArchive', logger: 'BoundLogger') -> None:
256219
super().normalize(archive, logger)
@@ -266,11 +229,6 @@ class KLinePath(Variables):
266229
""",
267230
)
268231

269-
def __init__(
270-
self, m_def: 'Section' = None, m_context: 'Context' = None, **kwargs
271-
) -> None:
272-
super().__init__(m_def, m_context, **kwargs)
273-
self.name = self.m_def.name
274232

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

0 commit comments

Comments
 (0)