def update(self, state, id, value):
   if id == "M":
     logger.info("Assigning new magnetic state M")
     module.assign(state.y, value)
     state.y.normalize(self.system.Ms)   # XXX: Is this a good idea? (Solution: Use unit magnetization everywhere.)
     state.flush_cache()
   else:
     raise KeyError(id)
 def update(self, state, id, value):
     if id == "M":
         logger.info("Assigning new magnetic state M")
         module.assign(state.y, value)
         state.y.normalize(
             state.Ms
         )  # XXX: Is this a good idea? (Solution: Use unit magnetization everywhere.)
         state.flush_cache()
     else:
         raise KeyError(id)
Ejemplo n.º 3
0
    def __setattr__(self, key, val):
        try:
            state = self.__state
            mask  = self.__mask
        except:
            return super(BodyProxy, self).__setattr__(key, val)

        old = getattr(state, key)
        if not isinstance(old, (Field, VectorField)):
            raise KeyError("For a single body, can only assign to model variables that contain a field or vector field: %s" % key)
        module.assign(old, val, mask)
        setattr(state, key, old)
Ejemplo n.º 4
0
                def __setattr__(this, key, val):
                    try:
                        state = this.__state
                        mask  = this.__mask
                    except:
                        return super(BodyProxy, this).__setattr__(key, val)

                    old = getattr(state, key)
                    if not isinstance(old, (Field, VectorField)):
                        raise KeyError("For a single body, can only assign to model variables that contain a field or vector field: %s" % key)
                    module.assign(old, val, mask)
                    setattr(state, key, old)