Nano-optics: A ring-resonator

70. Nano-optics: A ring-resonator#

from ring_resonator_import import *
from ngsolve import *
from ngsolve.webgui import Draw
0: 00000001011111010111110
Draw (mesh);
scene = Draw (gfu.components[0], order=3, min=-0.05, max=0.05, autoscale=False)

from time import time
ts = time()
with TaskManager(): 
    while t < tend:
        w.data = -fullB.T * gfu.vec

        ### time envelope for the src ################################################################
        if abs((t-tpeak)/tpeak) < 1:
           t_envelope = (2*exp(1)/sqrt(math.pi))*sin(2*math.pi*fcen*t)*exp (-1/(1-((t-tpeak)/tpeak)**2))
        else:
           t_envelope = 0

        w.data += t_envelope*Lsrc.vec
        w.data -= sigma * dampingp * gfu.vec
        w.data -= emb_p @ Bstab.mat.T * gfstab.vec

        gfu.vec.data += tau * invp * w
        
        w.data = fullB * gfu.vec
        hvstab.data = Bstab.mat @ emb_p.T * gfu.vec
        w.data -= sigma * dampingu * gfu.vec
        
        gfu.vec.data += tau * invu * w        
        gfstab.vec.data += tau * Mstabinv * hvstab

        t += tau
        i += 1
        if i%20 == 0:
            scene.Redraw()


print ("total time", time()-ts)
---------------------------------------------------------------------------
KeyboardInterrupt                         Traceback (most recent call last)
Cell In[3], line 6
      4 ts = time()
      5 with TaskManager(): 
----> 6     while t < tend:
      7         w.data = -fullB.T * gfu.vec
      9         ### time envelope for the src ################################################################

KeyboardInterrupt: 

B. Kapidani, J. Schöberl: A matrix-free Discontinuous Galerkin method for the time dependent Maxwell equations in unbounded domains (https://arxiv.org/abs/2002.08733)