예제 #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)
예제 #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
예제 #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
예제 #4
0
 def _update(self):
     if self._dirty:
         self.source_start, self.source_end = self.source_endpoints
         self.source_delta = self.source_end - self.source_start
         self.vector_value = unit_vector(self.source_delta)*self.value
     self._dirty == False