Exemple #1
0
    def set_source_parameters(self, source_parameters):
        """Set current fillament source paerameters using dict

        source_parameters is a dict with keys:

        I -- Source current in amperes
        endpoints -- 2x3 array with start and end coordinates of the source
        """
        self.source_parameters = source_parameters
        endpoints = source_parameters['endpoints']
        delta = endpoints[1] - endpoints[0]
        self.direction = unit_vector(delta)
        self.length = vector_length(delta)
Exemple #2
0
 def calculate_voltage(self, start_pt, end_pt):
     fn = self.field_function
     delta = end_pt - start_pt
     l_hat = unit_vector(delta)
     # Evaluate E . l_hat where E is the electric field vector and
     # l_hat is a unit vector along the integration path.
     eval_fn = lambda l: np.dot(l_hat, fn(*(start_pt + delta * l)))
     # Integrate over unit length
     intg = romberg(eval_fn, 0, 1)
     # Multiply by inteval length to de-normalise
     interval_len = vector_length(delta)
     intg = intg * interval_len
     return intg
Exemple #3
0
 def calculate_voltage(self, start_pt, end_pt):
     fn = self.field_function
     delta = end_pt - start_pt
     l_hat = unit_vector(delta)
     # Evaluate E . l_hat where E is the electric field vector and
     # l_hat is a unit vector along the integration path.
     eval_fn = lambda l: np.dot(l_hat, fn(*(start_pt + delta*l)))
     # Integrate over unit length
     intg = romberg(eval_fn, 0, 1)
     # Multiply by inteval length to de-normalise
     interval_len = vector_length(delta)
     intg = intg*interval_len
     return intg
Exemple #4
0
    def get_contribution(self):
        self._update()
        source_len = vector_length(self.source_delta)
        no_pts = self.no_integration_points
        if no_pts == 1:
            intg_pts = [self.source_start + self.source_delta*0.5]
        else:
            intg_pts = self.source_start + self.source_delta*np.linspace(
                0,1,no_pts)[:, np.newaxis]

        contribs = collections.defaultdict(lambda : 0.)
        point_magnitude = self.vector_value*source_len/no_pts
        for pt in intg_pts:
            dnos, vals = calc_pointsource_contrib(
                self.function_space, pt, point_magnitude)
            for dn, v in zip(dnos, vals):
                contribs[dn] = contribs[dn] + v

        dofnos = np.array(contribs.keys(), dtype=np.uint)
        rhs_contribs = np.array(contribs.values())
        return dofnos, rhs_contribs