コード例 #1
0
 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)
コード例 #2
0
 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)
コード例 #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)
コード例 #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)