Exemplo n.º 1
0
    def _update_boundary(self, x, y):

        N = self.waveguide_params.get("N")
        eta = self.waveguide_params.get("eta")
        print "N:", N
        print "eta: ", eta

        k0, k1 = [ np.sqrt(N**2 - n**2)*np.pi for n in 0, 1 ]
        L = abs(2*np.pi/(k0 - k1 + y))

        if neumann:
            WG = Neumann(L=L, loop_type='Constant', x_R0=x, y_R0=y,
                         **self.waveguide_params)
        else:
            WG = Dirichlet(L=L, loop_type='Constant', x_R0=x, y_R0=y,
                           **self.waveguide_params)
        self.WG = WG

        xi_lower, xi_upper = WG.get_boundary(eps=x, delta=y)

        np.savetxt("lower.profile", zip(WG.t, xi_lower))
        np.savetxt("upper.profile", zip(WG.t, xi_upper))

        N_file = len(WG.t)
        replacements = {'LENGTH': str(L),
                        'WIDTH': str(W),
                        'MODES': str(N),
                        'PPHW': str(self.pphw),
                        'GAMMA0': str(eta),
                        'NEUMANN': '0',
                        'N_FILE_BOUNDARY': str(N_file),
                        'BOUNDARY_UPPER': 'upper.boundary',
                        'BOUNDARY_LOWER': 'lower.boundary'}

        replace_in_file(self.template, self.xml, **replacements)
    def update_boundary(eps, delta):
        L = abs(2*np.pi/(kr + delta))

        # choose discretization such that r_nx < len(x_range)
        r_nx_L = (L*(N*pphw + 1)).astype(int)
        x_range = np.linspace(0, L, r_nx_L)

        # no Delta-phase necessary if looking at loop_type constant!
        WG = Dirichlet(loop_type='Constant', N=N, L=L, W=W, eta=eta)

        xi_lower, xi_upper = WG.get_boundary(x=x_range, eps=eps, delta=delta)
        print "lower.boundary.shape", xi_lower.shape

        np.savetxt("lower.boundary", zip(x_range, xi_lower))
        np.savetxt("upper.boundary", zip(x_range, xi_upper))

        N_file_boundary = len(x_range)
        replacements = {'NAME': CALC_NAME,
                        'LENGTH': str(L),
                        'WIDTH': str(W),
                        'MODES': str(N),
                        'PPHW': str(pphw),
                        'GAMMA0': str(eta),
                        'NEUMANN': "0",
                        'N_FILE_BOUNDARY': str(N_file_boundary),
                        'BOUNDARY_UPPER': 'upper.boundary',
                        'BOUNDARY_LOWER': 'lower.boundary'}

        replace_in_file(xml_template, xml, **replacements)
Exemplo n.º 3
0
def prepare_calc(
    x, N=None, L=None, W=None, pphw=None, linearized=None, xml_template=None, xml=None, loop_type=None, ncores=None
):
    """Prepare and simulate a waveguide with profile

        xi = xi(eps0, delta0, phase0)

    with a parametrization function determined by loop_type.
    """
    eps, delta, phase = x

    ep.potential.write_potential(
        N=N,
        pphw=pphw,
        L=L,
        W=W,
        x_R0=eps,
        y_R0=delta,
        init_phase=phase,
        loop_type=loop_type,
        boundary_only=True,
        shape="RAP",
        verbose=False,
        plot=False,
        linearized=linearized,
    )
    N_file = int(L * (pphw * N + 1))
    replacements = {
        "LENGTH": str(L),
        "WIDTH": str(W),
        "MODES": str(N),
        "PPHW": str(pphw),
        "GAMMA0": "0.0",
        "NEUMANN": "0",
        "N_FILE_BOUNDARY": str(N_file),
        "BOUNDARY_UPPER": "upper.boundary",
        "BOUNDARY_LOWER": "lower.boundary",
    }
    replace_in_file(xml_template, xml, **replacements)