aboutsummaryrefslogtreecommitdiff
path: root/src/devices/mzi.cpp
blob: 6999fd91eeebe2aa27bb0199c6dd910cb2ebb4c5 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
#include <mzi.h>

#define __modname(SUFFIX, IDX) \
    ((""s + this->name() + "_" + SUFFIX + to_string(IDX)).c_str())

using namespace std;

void MZI::init()
{
    DC1.reset();
    DC2.reset();
    PS1.reset();
    PS2.reset();
    WG1.reset();
    WG2.reset();

    // Creating instances
    WG1 = make_unique<Waveguide>((string(name()) + "/WG1").c_str(),
            m_length_cm, m_attenuation_dB_cm, m_neff, m_ng);
    WG2 = make_unique<Waveguide>((string(name()) + "/WG2").c_str(),
            m_length_cm, m_attenuation_dB_cm, m_neff, m_ng);
    DC1 = make_unique<DirectionalCoupler>((string(name()) + "/DC1").c_str(), 0.5, m_attenuation_coupler_dB);
    DC2 = make_unique<DirectionalCoupler>((string(name()) + "/DC2").c_str(), 0.5, m_attenuation_coupler_dB);
    PS1 = make_unique<PhaseShifter>((string(name()) + "/PS1").c_str(), m_attenuation_ps_dB);
    PS2 = make_unique<PhaseShifter>((string(name()) + "/PS2").c_str(), m_attenuation_ps_dB);

    // Connecting

    PS1->p_in(p_in1);
    PS1->p_out(w1);
    PS1->p_vin(p_vphi);

    DC1->p_in1(w1);
    DC1->p_in2(p_in2);
    DC1->p_out1(w2);
    DC1->p_out2(w5);

    // Upper branch
    PS2->p_in(w2);
    PS2->p_out(w3);
    PS2->p_vin(p_vtheta);

    WG1->p_in(w3);
    WG1->p_out(w4);

    // Bottom branch
    WG2->p_in(w5);
    WG2->p_out(w6);

    // End
    DC2->p_in1(w4);
    DC2->p_in2(w6);
    DC2->p_out1(p_out1);
    DC2->p_out2(p_out2);
}