Hi Zheng,

Thank you for your response. It is really faster than using
fields::total_energy().
But am I doing it right ? To calculate the total field energy in every step
I do :

double ex = fields->field_energy_in_box(meep::Ex, volume.surroundings());
double ey = fields->field_energy_in_box(meep::Ey, volume.surroundings());
double ez = fields->field_energy_in_box(meep::Ez, volume.surroundings());
double hx = fields->field_energy_in_box(meep::Hx, volume.surroundings());
double hy = fields->field_energy_in_box(meep::Hy, volume.surroundings());
double hz = fields->field_energy_in_box(meep::Hz, volume.surroundings());
double e=ex+ey+ez+hx+hy+hz;

Is it optimal ? It is still not as fast as the algorithm in Fortran I
mentioned earlier.

Thank you,
Thomas Jefferson

2008/7/28 Zheng Li <[EMAIL PROTECTED]>:
> Jefferson Thomas wrote:
>>
>> Hi,
>>
>> I want to calculate the total energy in my simulation for every step.
>> I am using the function fields::total_energy()
>> The problem is that it runs veeery slowly. It takes several times more
>> time than the actual step takes !
>> Is there any other way to calculate the energy faster ? It would be very
>> useful.
>> I know it is possible because I am using paralelly with meep a
>> photonic crystal simulation written in Fortran
>> and there the calculation of energy is a side product of the actual
>> FDTD calculation so the energy
>> data is simply available for every step without any additional
>> overhead. Is there something like that in meep ?
>>
>> Thank you for any help,
>> Thomas Jefferson
>>
>> _______________________________________________
>> meep-discuss mailing list
>> [email protected]
>> http://ab-initio.mit.edu/cgi-bin/mailman/listinfo/meep-discuss
>>
>>
>>
>
> Hi,
> If you use C++ interface and want to calculate the energy in each step, then
> I think you should circumvent fields::total_energy. Due to
> the different evaluating time and spacial points between the H and E fields
> in the
> Yee lattice, when you call the total_energy() function, meep should backup
>  the fields
> ,  run a  half step for H,  average the H  energy to get the right one and
>  restore the fields again,
> which is  obviously unsuitable for your case.  You can just record the H and
> E energy in each step
> with
> double fields::field_energy_in_box(component c,
>                  const geometric_volume &where);
> and average them by yourself.
>
> Zheng
> 2008-728
>

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

Reply via email to