Пример #1
0
  def __init__(self, mesh, initial_mag, m_sat, where=[1], order=1):
    MumagCore.__init__(self, mesh, where, m_sat, initial_mag, order)
    self.step_calculate_h_total = None

    # Default settings
    for p in euler_defaults: self.features[p] = euler_defaults[p]

    self.ID = None # Integer assigned by the parent 'Eulers' class
    self.parent_ID = None # The 'Eulers' instance which generated this object
Пример #2
0
    def __init__(self, mesh, initial_mag, m_sat, where=[1], order=1):
        MumagCore.__init__(self, mesh, where, m_sat, initial_mag, order)
        self.step_calculate_h_total = None

        # Default settings
        for p in euler_defaults:
            self.features[p] = euler_defaults[p]

        self.ID = None  # Integer assigned by the parent 'Eulers' class
        self.parent_ID = None  # The 'Eulers' instance which generated this object
Пример #3
0
    def setup(self):
        '''This function should be called after the method 'set' to setup
       the simulation (create the fields, the operators and so on)'''

        # Should not do initializizations more than once
        if self.is_ready: return

        self.damping = self.features["damping"]
        self.gamma_G = self.features["gamma_G"]
        self.gamma_LL = self.features["gamma_LL"]
        self.absolute_step_error = self.features["absolute_step_error"]
        self.relative_step_error = self.features["relative_step_error"]
        self.step_headroom = self.features["step_headroom"]
        self.stopping_time = self.features["stopping_time"]
        self.stopping_dm_dt = self.features["stopping_dm_dt"]
        self.max_iterations = self.features["max_iterations"]
        self.max_rejections = self.features["max_rejections"]
        self.initial_dt = self.features["initial_dt"]
        self.max_dt_ratio = self.features["max_dt_ratio"]
        self.initial_time = self.features["initial_time"]
        self.time = 0.0

        MumagCore.setup(self)

        # self.llg_gamma_LL == None if llg_gamma_G is given by the user
        if self.gamma_LL == None:
            self.gamma_LL = self.gamma_G / (1.0 + self.damping**2)

        self.new_field("old_m", indices=[3], initial_values=self.initial_mag)
        self.new_field("dm_dt", indices=[3])
        self.new_field("old_dm_dt", indices=[3])
        self.new_field("delta_t", indices=[])

        # Just some shorthands for what follows
        mwe_m = self.mwes["m"]
        field_m = self.fields["m"]

        # The auxiliary arguments passed from python to C
        args_names = [
            "time", "dt", "old_max_norm_dm_dt", "llg_damping", "llg_gamma_LL",
            "absolute_step_error", "relative_step_error", "step_headroom",
            "m_sat"
        ]

        # Create the C-functions which perform the different parts
        # of the computation

        # The fields which will be passed to 'step_make' and 'step_check'
        some_names = [
            "m", "old_m", "dm_dt", "old_dm_dt", "delta_t", "h_ext", "h_total",
            "h_demag", "h_exch"
        ]
        some_mwes = self.mwe_list(some_names)
        some_fields = self.field_list(some_names)

        # Called to execute the euler step (calculate the new m and the
        # value of old_norm_dm_dt needed for the computation of the error)
        c_step_make = nfem.site_wise_applicator(args_names,
                                                ccode_step_make,
                                                field_mwes=some_mwes)

        def step_make(time, dt):
            self.old_max_norm_dm_dt = 0.0
            aux_arg_list = [
                time, dt, self.old_max_norm_dm_dt, self.damping, self.gamma_LL,
                self.absolute_step_error, self.relative_step_error,
                self.step_headroom, self.m_sat
            ]
            modified_args = c_step_make(aux_arg_list, fields=some_fields)
            self.old_max_norm_dm_dt = modified_args[2]

        #----------------------End of definition of the function step_make
        self.step_make = step_make

        c_step_check = nfem.site_wise_applicator(args_names,
                                                 ccode_step_check,
                                                 field_mwes=some_mwes)

        def step_check(time, dt):
            aux_arg_list = [
                time, dt, self.old_max_norm_dm_dt, self.damping, self.gamma_LL,
                self.absolute_step_error, self.relative_step_error,
                self.step_headroom, self.m_sat
            ]
            c_step_check(aux_arg_list, fields=some_fields)

        #----------------------End of definition of the function step_check
        self.step_check = step_check

        self.c_calculate_next_dt = nfem.site_wise_applicator(
            ["accepted_step", "previous_dt"],
            ccode_calculate_next_dt,
            field_mwes=[self.mwes["delta_t"]])

        self.step_calculate_h_total = self.calculate_h_total
        self.is_ready = True
        self.next_stage(time=self.initial_time)
Пример #4
0
  def setup(self):
    '''This function should be called after the method 'set' to setup
       the simulation (create the fields, the operators and so on)'''

    # Should not do initializizations more than once
    if self.is_ready: return

    self.damping = self.features["damping"]
    self.gamma_G = self.features["gamma_G"]
    self.gamma_LL = self.features["gamma_LL"]
    self.absolute_step_error = self.features["absolute_step_error"]
    self.relative_step_error = self.features["relative_step_error"]
    self.step_headroom = self.features["step_headroom"]
    self.stopping_time = self.features["stopping_time"]
    self.stopping_dm_dt = self.features["stopping_dm_dt"]
    self.max_iterations = self.features["max_iterations"]
    self.max_rejections = self.features["max_rejections"]
    self.initial_dt = self.features["initial_dt"]
    self.max_dt_ratio = self.features["max_dt_ratio"]
    self.initial_time = self.features["initial_time"]
    self.time = 0.0


    MumagCore.setup(self)

    # self.llg_gamma_LL == None if llg_gamma_G is given by the user
    if self.gamma_LL == None:
      self.gamma_LL = self.gamma_G/(1.0+self.damping**2)

    self.new_field("old_m", indices=[3], initial_values=self.initial_mag)
    self.new_field("dm_dt", indices=[3])
    self.new_field("old_dm_dt", indices=[3])
    self.new_field("delta_t", indices=[])

    # Just some shorthands for what follows
    mwe_m = self.mwes["m"]
    field_m = self.fields["m"]

    # The auxiliary arguments passed from python to C
    args_names = ["time", "dt", "old_max_norm_dm_dt",
      "llg_damping", "llg_gamma_LL",
      "absolute_step_error", "relative_step_error", "step_headroom",
      "m_sat"]

    # Create the C-functions which perform the different parts
    # of the computation

    # The fields which will be passed to 'step_make' and 'step_check'
    some_names = ["m", "old_m", "dm_dt", "old_dm_dt", "delta_t", "h_ext",
     "h_total", "h_demag", "h_exch"]
    some_mwes = self.mwe_list(some_names)
    some_fields = self.field_list(some_names)

    # Called to execute the euler step (calculate the new m and the
    # value of old_norm_dm_dt needed for the computation of the error)
    c_step_make = nfem.site_wise_applicator(args_names,
      ccode_step_make, field_mwes=some_mwes)
    def step_make(time, dt):
      self.old_max_norm_dm_dt = 0.0
      aux_arg_list = [time, dt, self.old_max_norm_dm_dt, self.damping,
        self.gamma_LL, self.absolute_step_error, self.relative_step_error,
        self.step_headroom, self.m_sat]
      modified_args = c_step_make(aux_arg_list, fields=some_fields)
      self.old_max_norm_dm_dt = modified_args[2]
    #----------------------End of definition of the function step_make
    self.step_make = step_make

    c_step_check = nfem.site_wise_applicator(args_names,
      ccode_step_check, field_mwes=some_mwes)

    def step_check(time, dt):
      aux_arg_list = [time, dt, self.old_max_norm_dm_dt, self.damping,
       self.gamma_LL, self.absolute_step_error, self.relative_step_error,
       self.step_headroom, self.m_sat]
      c_step_check(aux_arg_list, fields=some_fields)
    #----------------------End of definition of the function step_check
    self.step_check = step_check

    self.c_calculate_next_dt = nfem.site_wise_applicator(
      ["accepted_step", "previous_dt"], ccode_calculate_next_dt,
      field_mwes=[self.mwes["delta_t"]])

    self.step_calculate_h_total = self.calculate_h_total
    self.is_ready = True
    self.next_stage(time=self.initial_time)