Steven G. Johnson wrote:
On Tue, 9 May 2006, paul wrote:

Could you give a breif corresponsding part to c++ interface if possible? How can I use self defiend source amplitude function in c++ interface?

I want to compute a ATR prism with Gaussian beam in 2D.


In C++ you would use:

    void fields::add_volume_source(component c, const src_time &src,
                         const geometric_volume &,
                         complex<double> A(const vec &),
                         complex<double> amp = 1.0);

and pass the function you want for the A parameter in order to specify the amplitude function.
Hi Steven:

Thanks for your hints,

I just tried to construct, it seems to work.

Could you just give me some comments? The animation is not very smooth?

Can I use similar things to compute a ATR prism with thin gold layer with Drude model? I think I also need to write a code for exploration the near field to far field to check the reflection dip.

Please have a review,

Regards,
#include <meep.hpp>
using namespace meep;

double eps(const vec &p) {
  if (p.x() < 10 && p.y() < 5)
    return 1.1;
  return 1.0;
}

complex<double> one(const vec &p) {
 //return 1;
 return (0.0,exp(-2*pi*p.x()*(0.3,0.4)));
}

int main(int argc, char **argv) {
  initialize mpi(argc, argv); // do this even for non-MPI Meep
  double resolution = 10; // pixels per distance 20
  volume v = vol2d(10,10, resolution); // 5x10 2d cell
  structure s(v, eps, pml(1.0));
  fields f(&s);
  
  f.output_hdf5(Dielectric, v.surroundings());
  double freq = 0.5, fwidth = 0.1;
  //gaussian_src_time src(freq, fwidth);
  continuous_src_time src(freq, fwidth);
  geometric_volume src_plane(vec(4,0),vec(0,0));
  f.add_volume_source(Hz,src,src_plane,one,1.0);
  
  //f.add_point_source(Ey, src, vec(5, 2)); //1.1 2.3
  master_printf("volume sources added...\n");
  //f.add_point_source(Ey, src, vec(4, 6)); //1.1 2.3
  f.solve_cw(1e-14,100000,2);
  master_printf("cw solved...\n");
  for(int i=0; i<50;i++){
  f.step();
  }
  for(int i=0; i<60;i++){
  f.step();
  //f.output_hdf5(Hx, v.surroundings());
  //f.output_hdf5(Hy, v.surroundings());
  f.output_hdf5(Hz, v.surroundings());  
  f.output_hdf5(Ey, v.surroundings());
  f.output_hdf5(Ex, v.surroundings());
  }
  return 0;
} 


CC = g++
CFLAGS = -O2 -I/usr/local/include 
CPPFLAGS = -I/usr/local/lib/hdf5-1.6.5/hdf5/include/ 
CXXFLAGS = -O2 -malign-double -march=pentium3
CYGPATH_W = echo
DEFS = -DHAVE_CONFIG_H
DEPDIR = .deps
ECHO = echo
ECHO_C = 
ECHO_N = -n
ECHO_T = 
EGREP = grep -E
EXEEXT = 
F77 = g77
FFLAGS = -g -O2
GEN_CTL_IO = gen-ctl-io
HARMINV_CFLAGS = -I/usr/local/include  
HARMINV_LIBS = -L/usr/local/lib -L/usr/lib/gcc-lib/i386-redhat-linux/3.2.2 
-L/usr/lib/gcc-lib/i386-redhat-linux/3.2.2/../../.. -lharminv -llapack -lblas 
-lfrtbegin -lg2c -lm -lgcc_s  
HAVE_GUILE_CONFIG = yes
LDFLAGS = -L/usr/local/lib/hdf5-1.6.5/hdf5/lib/
MEEPLIBS = -L/usr/local/lib/hdf5-1.6.5/hdf5/lib/ -L/usr/local/lib/libmeep.la 
-lhdf5 -lz -L/usr/local/lib -L/usr/lib/gcc-lib/i386-redhat-linux/3.2.2 
-L/usr/lib/gcc-lib/i386-redhat-linux/3.2.2/../../.. -lharminv -llapack -lblas 
-lfrtbegin -lg2c -lm -lgcc_s   -lfftw3 -lm -lmeep 

Test1.o : Test.cpp meep.hpp
        ${CC} ${CFLAGS} ${CPPFLAGS} ${CXXFLAGS} ${DEFS} -c Test.cpp

all : Test.o
        ${CC} ${CFLAGS} Test.o ${LDFLAGS}  ${MEEPLIBS} ${HARMINV_LIBS} -o test2

clean :
        rm -rf *.o test2 *.h5

        

PNG image

PNG image

_______________________________________________
meep-discuss mailing list
[email protected]
http://ab-initio.mit.edu/cgi-bin/mailman/listinfo/meep-discuss

Reply via email to