Hello all,
After simulating a trivial example with MEEP, I have found that the results of
the computation of the electric (magnetic, electric+magnetic) field energy in a
cube obtained using libctl and C++ interfaces slightly (~0.1-1%) differ. This
examle is a 16x16x16 cube with PML boundaries and isotropic constant epsilon; a
continuous-wave point dipole as a source. The energy is calculated in the 4x4x4
cube at the center. Epsilon averaging is not used. The libctl and C++ files are
attached here. I think that all the comutations are done by the same libmeep
and should be identical or have discrepancies on the order of 1e-16.
My system is Slackware Linux 14.1 x86_64 with gcc-4.8.2, I tried this on AMD
and
Intel core 5 CPU. I have installed the latest relesad versions of Meep, Guile,
Libctl. Everything is compiled with "-O2 -fPIC" options, Meep has not MPI
support.
--
Andrey V. Panov
http://canopus.iacp.dvo.ru/~panov/
(set! progress-interval infinity)
(define-param sz 16) ; size of cell
(define-param flsz 4) ; size of block for energy caclculation
(set! geometry-lattice (make lattice (size sz sz sz)))
(define-param sourcex (- 2 (/ sz 2))) ;
(define-param eps 2)
(define-param fcen 0.15) ; frequency of source
(define Amp 1.0) ; amplitude of source
(define-param dpml 1.0) ; PML layer thickness
(define ener 0.0)
(define dE 0.0)
(define timemean 20.0) ; the time for averaging
(define in_time 5.0)
(set! resolution 10)
(define dT (* 0.5 (/ 1.0 resolution)))
(define (my-output) (set! dE (electric-energy-in-box (volume (center 0 0 0 )
(size flsz flsz flsz))))
(print "time=" (meep-time) " dU_E=" dE "\n")
(set! ener (+ ener dE))
)
(set! eps-averaging? false)
;(set! mat (material (make dielectric (epsilon 2.25))))
(set! geometry (list
(make block (center 0 0 0) (size infinity infinity infinity)
(material (make dielectric (epsilon eps) )))
)
)
(set! sources (list
(make source
(src (make continuous-src (frequency fcen)))
(component Ez)
(center 0 sourcex 0) (size 0 0 0)
(amplitude Amp))))
(set! pml-layers (list (make pml (thickness dpml))))
(set! ener 0.0)
(run-until in_time)
(run-until timemean (at-every dT my-output))
(print "final E_U " ener "\n")
#include <meep.hpp>
using namespace meep;
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
double eps(const vec &p) {
return 2.0;
}
int main(int argc, char **argv) {
initialize mpi(argc, argv);
//quiet = true;
const double resolution = 10;
const double sz = 16;
const double flsz = 4;
double Amp = 1.0;
const double in_time = 5.0;
const double timemean = 20.0;
double ener, dE;
double env_max = flsz/2.0, env_min = - flsz/2.0;
grid_volume v = vol3d(sz, sz, sz, resolution);
v.center_origin();
structure s(v, eps, pml(1.0));
fields f(&s);
f.use_real_fields();
double w = 0.15; // frequency of source
continuous_src_time src(w);
volume ener_vol(vec(env_min, env_min, env_min), vec(env_max, env_max, env_max));
ener = 0.0;
f.add_point_source(Ez, src, vec(0.0, 2.0 - sz/2.0, 0.0), Amp);
while (f.time() < in_time) {
f.step();
}
while (f.time() < in_time + timemean) {
f.step();
dE = f.electric_energy_in_box(ener_vol);
ener += dE;
printf("time=%g dU_E = %18.15g\n", f.time(), dE);
}
printf("final E_U %18.15g\n", ener);
return 0;
}
_______________________________________________
meep-discuss mailing list
meep-discuss@ab-initio.mit.edu
http://ab-initio.mit.edu/cgi-bin/mailman/listinfo/meep-discuss