Hello,
I have a code for electromagnetics simulation and analysis in FreeFem over a time period. I need to extract three different files. One is a file that contains all the coordinates, the second one is the indices of the nodes that are creating each element in mesh that corresponds to the previous file, and the last one is the current density based on the defined formula. Here is the important part of the code:
// problem
problem eddyCurrent(Az, v) = int2d(Th)(nu0 * Grad(Az)’ * Grad(v)) + int2d(Th)(alpha * Az * v / dt) - int2d(Th)(alpha * Azold * v / dt) - int2d(Th)(J * v) + on(C2, Az = 0);
ofstream ffJz(“Jz_AllTimesteps.txt”);
// time iteration
for(real t = 0; t < T; t += dt)
{
Azold = Az;
// update total current from the power supply
J = J0 * Ipk * sin(2.0*pi*f*t);
// solve
eddyCurrent;
Ph Jz = -J + alpha * (Az - Azold) / dt;
// This part is not working.
//for (int i = 0; i < Th.nt; i++) {
// for (int j = 0; j < 3; ++j) {
// ffJz << Jz[][Vh(i, j)] << " ";
// }
//}
cout << "current time = " << t << " sec" << endl;
cout << "total current (by integration) = " << int1d(Th, C1)(nu0 * (- dy(Az) * N.y - dx(Az) * N.x)) << " Amp" << endl;
cout << "total current (by source) = " << Ipk * sin(2 * pi * f * t) << " Amp" << endl;
plot(Az, wait = true, fill = true, value = true);
}
I am new to FreeFem, so I appreciate your help.
Regards,
Mehran