Exemplo n.º 1
0
    def set_value(self, value):
        if not self.vivified:
            return Quantity.set_value(self, value)

        if value == None:
            return

        if not isinstance(value, Value):
            raise ValueError(
                "The argument of set_value has type '%s', but "
                "it should rather be an instance of the Value "
                "class." % type(value)
            )

        if self.def_on_mat:
            set_plan = value.get_set_plan(self.material_names, unit=self.unit)
            for v, m, u in set_plan:
                scale_factor = float(u)
                fn = "%s_%s" % (self.name, v)
                flexible_set_fielddata(self.master, fn, m, 1e-9, scale_factor=scale_factor, normalise=self.normalized)

        else:
            set_plan = value.get_set_plan(self.material_names, unit=self.unit)
            assert len(set_plan) == 1
            v, m, u = set_plan[0]
            scale_factor = float(u)
            flexible_set_fielddata(
                self.master, self.name, m, 1e-9, scale_factor=scale_factor, normalise=self.normalized
            )

        ocaml.lam_set_field(self.lam, self.master, self.get_lam_name())
Exemplo n.º 2
0
def update_H_ext(t_su):
    t = SI(1e-12, 's')*t_su
    GHz = 1e9/SI('s')
    frequency = 10*GHz
    amplitude = math.sin(float(math.pi*frequency*t))
    fieldname = 'H_ext'
    s._fields.set_subfield(None, # subfieldname
                           [0, amplitude, 0],
                           SI(0.4e6, 'A/m'),
                           fieldname=fieldname,
                           auto_normalise=False)
    (mwe, field) = s._master_mwes_and_fields_by_name[fieldname]
    ocaml.lam_set_field(s._lam, field, "v_" + fieldname)
    print "*",
Exemplo n.º 3
0
    def set_value(self, value):
        if not self.vivified:
            return Quantity.set_value(self, value)

        if value == None:
            return

        if not isinstance(value, Value):
            raise ValueError("The argument of set_value has type '%s', but "
                             "it should rather be an instance of the Value "
                             "class." % type(value))

        if self.def_on_mat:
            set_plan = value.get_set_plan(self.material_names, unit=self.unit)
            for v, m, u in set_plan:
                scale_factor = float(u)
                fn = "%s_%s" % (self.name, v)
                flexible_set_fielddata(self.master,
                                       fn,
                                       m,
                                       1e-9,
                                       scale_factor=scale_factor,
                                       normalise=self.normalized)

        else:
            set_plan = value.get_set_plan(self.material_names, unit=self.unit)
            assert len(set_plan) == 1
            v, m, u = set_plan[0]
            scale_factor = float(u)
            flexible_set_fielddata(self.master,
                                   self.name,
                                   m,
                                   1e-9,
                                   scale_factor=scale_factor,
                                   normalise=self.normalized)

        ocaml.lam_set_field(self.lam, self.master, self.get_lam_name())