class Anisotropy(QuantityContainer): """The anisotropy base class.""" anisotropy_id = 0 def __init__(self, allowed_quantities=None): # Every anisotropy needs to have an unique name, so that we can assign # a unique name to its parameters within the same model. # Example: if we define two uniaxial anisotropies, then we have two # sets of constants (K1, K2). We then name them as ("u1_K1", "u1_K2") # for the first anisotropy and ("u2_K1", "u2_K2") for the second one. self.name = "a%d" % Anisotropy.anisotropy_id Anisotropy.anisotropy_id += 1 QuantityContainer.__init__(self, allowed_quantities) self.quantities = Quantities() self.quantities_defined = False def _create_quantity(self, q_type, q_name, *args, **named_args): q_absname = "%s_%s" % (self.name, q_name) q = QuantityContainer._create_quantity(self, q_type, q_name, q_absname, *args, **named_args) # We add the object to the group without the prefix which is # identifying the anisotropy self.quantities.add(q) return q def _define_quantities(self): self.quantities_defined = True def get_E_equation(self): raise NotImplementedError("get_E_equation not implemented, yet.") def get_H_equation(self): raise NotImplementedError("get_H_equation not implemented, yet.")
class Anisotropy(QuantityContainer): """The anisotropy base class.""" anisotropy_id = 0 def __init__(self, allowed_quantities=None): # Every anisotropy needs to have an unique name, so that we can assign # a unique name to its parameters within the same model. # Example: if we define two uniaxial anisotropies, then we have two # sets of constants (K1, K2). We then name them as ("u1_K1", "u1_K2") # for the first anisotropy and ("u2_K1", "u2_K2") for the second one. self.name = "a%d" % Anisotropy.anisotropy_id Anisotropy.anisotropy_id += 1 QuantityContainer.__init__(self, allowed_quantities) self.quantities = Quantities() self.quantities_defined = False def _create_quantity(self, q_type, q_name, *args, **named_args): q_absname = "%s_%s" % (self.name, q_name) q = QuantityContainer._create_quantity(self, q_type, q_name, q_absname, *args, **named_args) # We add the object to the group without the prefix which is # identifying the anisotropy self.quantities.add(q) return q def _define_quantities(self): self.quantities_defined = True def get_E_equation(self): raise NotImplementedError("get_E_equation not implemented, yet.") def get_H_equation(self): raise NotImplementedError("get_H_equation not implemented, yet.")
def __init__(self, allowed_quantities=None): # Every anisotropy needs to have an unique name, so that we can assign # a unique name to its parameters within the same model. # Example: if we define two uniaxial anisotropies, then we have two # sets of constants (K1, K2). We then name them as ("u1_K1", "u1_K2") # for the first anisotropy and ("u2_K1", "u2_K2") for the second one. self.name = "a%d" % Anisotropy.anisotropy_id Anisotropy.anisotropy_id += 1 QuantityContainer.__init__(self, allowed_quantities) self.quantities = Quantities() self.quantities_defined = False
def __init__(self, allowed_quantities=None): # Every anisotropy needs to have an unique name, so that we can assign # a unique name to its parameters within the same model. # Example: if we define two uniaxial anisotropies, then we have two # sets of constants (K1, K2). We then name them as ("u1_K1", "u1_K2") # for the first anisotropy and ("u2_K1", "u2_K2") for the second one. self.name = "a%d" % Anisotropy.anisotropy_id Anisotropy.anisotropy_id += 1 QuantityContainer.__init__(self, allowed_quantities) self.quantities = Quantities() self.quantities_defined = False