Re: Vector Poisson Equation for a 3D Current Source

Posted by Precise Simulation on
URL: http://forum.featool.com/Vector-Poisson-Equation-for-a-3D-Current-Source-tp338p362.html

ADSW1243 wrote
Currently it is of the form: [Jx,Jy,Jz] = J_coeff(x,y,z,N_wire,I_mag,mu_o).

1. Do I need to split this into 3 functions which only output one of J1, J2, J3?
Yes, but you can potentially use the "persistent" variables in a function "wrapper" to only calculate Jx-z once, for example:

function [ Ji ] = J_coeff_i( x, y, z, i_component )
  persistent Jx Jy Jz
  if( isempty(Jx) || ~isequal(size(x),size(Jx)) )
    [Jx,Jy,Jz] = J_coeff(x,y,z,N_wire,I_mag,mu_o);
    Jx = reshape(Jx,size(x));
    Jy = ...
  end
  switch i_component
    case 1
      Ji = Jx;
    ...
  end

You would then define J1-3 using the wrapper as "J1 := J_coeff_i(x,y,z,1)" etc ... If FEATool can find the function it will call it with the arguments. Note, that the output must have the same size as the input coordinates (for example using the reshape command).

ADSW1243 wrote
2. In my geometry for the initial problem, I have two sub-domains: an internal coil of the type discussed above, surrounded by a 'universe' box which forms a typical black-box setup. Currently if I understand the GUI correctly, I set Jx as a constant which seems to apply to both sub-domains. The expectation is that this will only apply to the internal sub-domain, but the values in the outer-sub-domain call the internal as a 3D source. How do I approach ensuring this is achieved? I thought perhaps a different equation is needed for each sub-domain, but I am unsure.
Assuming "J1" is defined in your equation, and you define an expression "J1". If the expression J1 is a scalar it will be valid for all subdomains, but if you define it as a space separated list, each entry will be used for the corresponding subdomains, for example "J1 := '1 0'" would set J1 to one in subdomain 1 and zero in subdomain 2.