Module voltrace.solver
The solver module assembles the BEM matrix, solves for the surface charge
distribution, and returns the resulting field. The top-level entry points are
solve_direct(), solve_fmm(), solve_direct_superposition(), and solve_fmm_superposition().
Functions
def solve_direct(excitation, method='constant', preexisting_field=None)-
Solve for the charges on the surface of the geometry by using a direct method and taking into account the specified excitation.
Parameters
excitation:Excitation- The excitation that produces the resulting field.
method:str- The method can be 'constant' or 'singularity'. The constant method computes constant charge density on every element. The singularity method attempts to explicitely account for charge singularities at edges using higher order polynomials. This is an experimental feature.
preexisting_field:Field, optional- An externally applied field (for example a
ConstantElectrostaticFieldorConstantMagnetostaticField) that is present before the geometry is introduced. It is taken into account when computing the induced charges on dielectric (electrostatic component) and magnetizable (magnetostatic component) materials. Note that the returned field only contains the contribution of the induced charges; addpreexisting_fieldto it to obtain the total field.
Returns
def solve_direct_superposition(excitation, method='constant', preexisting_field=None)-
When using superposition multiple fields are computed at once. Each field corresponds with an excitation of an electrode that was assigned a non-zero fixed voltage (or current) value. This is useful when a geometry needs to be analyzed for many different voltage (or current) settings. In this case taking a linear superposition of the returned fields allows to select a different voltage 'setting' without inducing any computational cost. There is no computational cost involved in using
superposition=Truesince a direct solver is used which easily allows for multiple right hand sides (the matrix does not have to be inverted multiple times). However, position dependent voltages are invalid in the superposition process.Parameters
excitation:Excitation- The excitation that produces the resulting field.
method:str- The method can be 'constant' or 'singularity'. The constant method computes constant charge density on every element. The singularity method attempts to explicitely account for charge singularities at edges using higher order polynomials. This is an experimental feature.
preexisting_field:Field, optional- An externally applied field (for example a
ConstantElectrostaticFieldorConstantMagnetostaticField) that is present before the geometry is introduced. It is taken into account when computing the induced charges on dielectric (electrostatic component) and magnetizable (magnetostatic component) materials.
Returns
FieldSuperpositionEach key is the name of an electrode on which a voltage (or current) was applied, the corresponding values are the fields. def solve_fmm(excitation, n_box=256, l_max=12, rtol=1e-08, preexisting_field=None)-
Solve for the charges on the surface of the geometry by using a fast multipole method (FMM) and taking into account the specified excitation. The FMM works by diving the geometry up into boxes, and using approximation formulas to compute the potential interaction of elements that are 'far apart'.
Parameters
excitation:Excitation- The excitation that produces the resulting field.
n_box:int- The maximum number of triangles to put into every box when dividing up the geometry. A larger number usually improves accuracy (and sometimes performance) but increases memory usage.
l_max:int- The order of the multipole expansions used to compute the far-away interactions. A larger number improves accuracy but increases the solve time.
rtol:float- The relative tolerance to achieve to stop the iterative solver:
norm(b - A @ x) <= rtol*norm(b)where b is the right hand side and A the matrix. preexisting_field:Field, optional- An externally applied field (for example a
ConstantElectrostaticField) that is present before the geometry is introduced. It is taken into account when computing the induced charges on dielectric materials.
Returns
def solve_fmm_superposition(excitation, n_box=256, l_max=12, rtol=1e-08, preexisting_field=None)-
When using superposition multiple fields are computed. Each field corresponds with an excitation of an electrode that was assigned a non-zero fixed voltage (or current) value. This is useful when a geometry needs to be analyzed for many different voltage (or current) settings. In this case taking a linear superposition of the returned fields allows to select a different voltage 'setting' without inducing any computational cost. Note that unlike the direct method the fast multipole method (FMM) uses an iterative solver and therefore needs to redo the entire solve step for every unity excitation.
Parameters
excitation:Excitation- The excitation that produces the resulting field.
n_box:int- The maximum number of triangles to put into every box when dividing up the geometry. A larger number usually improves accuracy (and sometimes performance) but increases memory usage.
l_max:int- The order of the multipole expansions used to compute the far-away interactions. A larger number improves accuracy but increases the solve time.
rtol:float- The relative tolerance to achieve to stop the iterative solver:
norm(b - A @ x) <= rtol*norm(b)where b is the right hand side and A the matrix. preexisting_field:Field, optional- An externally applied field (for example a
ConstantElectrostaticField) that is present before the geometry is introduced. It is taken into account when computing the induced charges on dielectric materials.
Returns
FieldSuperpositionEach key is the name of an electrode on which a voltage (or current) was applied, the corresponding values are the fields.