[Scilab-users] Calculate electrical field with Scifreefem

iiyama mi.jaritz at gmail.com
Sun Jun 29 00:26:24 CEST 2014


Dear all
I want to use Scifreefem for calculating the electrical field between two
wires. I managed to solve the laplace equation for the voltage but I was not
able to implement the right code for the electrical field (E=-grad(V)). I
would be grateful for your information.Thx

Code:
// Standard formulation problem, Equations are described in FreeFeem
language.
clear 
close
clc
// User can enable / disable graphics by setting Graphics variable to %t or
%f
if ~exists('Graphics') then
  Graphics = %t;
end

if Graphics then
  xset('wdim',700,700);
  xset('colormap',jetcolormap(254));
  colorbar(-100,100)
end

// Definition of the border

deff('[x,y] = f1(t)','x = 1+0.5*cos(t); y = 1+0.5*sin(t)'); //Linker Kreis
deff('[x,y] = f2(t)','x = 3+0.5*cos(t); y = 1+0.5*sin(t)'); //Rechter Kreis


bord2 = tlist(['border';'a';'b';'c';'d';'e';'f'],...
        list('x = t; y = 0',0,5,40,1),...
        list('x = 5; y = t',0,2,20, 1),...
        list('x = 5 - t; y = 2',0,5,40,1),...
        list('x = 0; y = t',2,0,20,1),...
        list(valf(f1, 0:2*%pi/100:2*%pi), 1),...
        list(valf(f2, 0:2*%pi/100:2*%pi), -1));
//
buildMesh(bord2,'th');
[noeul,trianl] = getffResult(); // Get mesh description in Scilab

erreur = 0.1;
coef   = 0.1^(1./5.); // Error level will be divided by 10 every 5
iterations.

[noeul,trianl] = getffResult(); // Get mesh description in Scilab

u = defvar('u'); // Set the unknown
f = defvar('0'); // Set the right hand side of the equation


  ff_problem(strcat(['solve(u)  {',...
	             pde_sol(u,div(grad(u)),f),...
                 'on(a,b,c,d) u = 0;...
                 on(e) u = 100;...
                 on(f) u = -100;};']));
//                     'on(a,b,c,d,e,f) u = 0; };']));
                   
  // Get the result as a Scilab variable
[noeul,trianl,tFunc] = getffResult('u');
 
    clf(); //xsetech([0,0,1,0.5]);
xsetech([0,0,1,1]);
  resultvisu(noeul,trianl,tFunc);
  colorbar(-100,100)

ff_end(); // Destroy Fem interpretor







--
View this message in context: http://mailinglists.scilab.org/Calculate-electrical-field-with-Scifreefem-tp4030798.html
Sent from the Scilab users - Mailing Lists Archives mailing list archive at Nabble.com.



More information about the users mailing list