Beispiel #1
0
 def minimise(self):
     if isinstance(self.evolver, Minimiser):
         self.create_mif()
         self.execute_mif()
     else:
         raise JoommfError("Joommf: You must add a valid minimisation"
                           " evolver to the simulation object")
Beispiel #2
0
 def run(self):
     if isinstance(self.evolver, LLG):
         self.create_mif()
         self.execute_mif()
     else:
         raise JoommfError("Joommf: You must add a valid time"
                           " evolver to the simulation object")
Beispiel #3
0
 def __init__(self, H):
     energy.__init__(self, "FixedZeeman")
     self.H = H
     if len(H) != 3:
         raise JoommfError(
             "Joommf: FixedZeeman only supports length"
             " 3 vectors at the present time")
Beispiel #4
0
 def __init__(self, m_init, Ms, d_mxHxm=0.1, name=None):
     if isinstance(m_init, str):
         if os.isfile(m_init):
             self.m_init = m_init
         else:
             raise JoommfError("Magnetisation file not found")
     else:
         self.m_init = m_init
     # Want to throw a warning here if neither
     self.Ms = Ms
     self.d_mxHxm = d_mxHxm
     self.name = name
Beispiel #5
0
 def add_output(self, output, stage=1):
     if not self.evolver:
         raise JoommfError("Joommf: You must add an evolver before "
                           "scheduling outputs, as some evolvers do "
                           "not support certain outputs.")
     if isinstance(self.evolver, LLG):
         if output in time_evolver_outputs:
             self.evolver_outputs.append([output, stage])
         elif output in minimizer_outputs:
             raise JoommfError("Joommf: This output is not supported by"
                               " time integrator evolvers.")
     elif isinstance(self.evolver, Minimiser):
         if output in minimizer_outputs:
             self.evolver_outputs.append([output, stage])
         elif output in time_evolver_outputs:
             raise JoommfError("Joommf: This output is not supported by"
                               " minimization evolvers.")
     elif output in field_outputs:
         self.field_outputs.append([output, stage])
     else:
         raise JoommfError("Joommf: This output was not understood."
                           " Please check that it is supported.")
Beispiel #6
0
    def set_evolver(self, evolver):
        if isinstance(evolver, Evolver):
            if self.evolver:
                print("Joommf: Evolver already set for this Sim object."
                      "\n This will be replaced with the new object")
            self.evolver = evolver

        else:
            raise JoommfError("Joommf: You must add a valid evolver from"
                              "the drivers/evolver module. If you are "
                              "trying to extend the functionality by adding"
                              "support for a new evolver, the new evolver "
                              "must be a subclass of Evolver")
Beispiel #7
0
 def execute_mif(self):
     process = o.call_oommf('boxsi ' + self.mif_filename)
     while True:
         output = process.stdout.readline()
         stderr = process.stderr.readline()
         if output == '' and process.poll() is not None:
             break
         elif self.debug:
             print(output)
             print(stderr)
     return_code = process.poll()
     if return_code != 0:
         raise JoommfError("Joommf: OOMMF failed to execute.")
     self.ODTFile = odtreader.ODTFile(self.mif_filename[:-3] + 'odt')
     self.df = self.ODTFile.df