aboutsummaryrefslogtreecommitdiff
path: root/src/devices/crow.cpp
blob: d411aa2a31d11fe05d2589ee0ab3e087d8aff99c (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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
#include <crow.h>

using namespace std;

void CROW::connect_submodules()
{
    // Physical parameters of the components
    // double neff = 2.6391; //2.2;
    // double ng = 4.3416; //neff;
    // double loss_db_cm = 2; //1;
    // double coupling_through = (1 - pow(0.83645, 2.0));//0.85;
    // double coupling_through = 1 - pow(0.83645, 2.0);//0.85;
    // double coupling_through = 1 - pow(0.83645, 2.0);//0.85;
    // coupling_through = 1 - 0.83645;//0.85;
    //double pi_length = 1.55e-6/2/neff;
    //double internal_length = 200*pi_length;
    //double internal_length = 1001*pi_length;
    // double internal_length = 2.0*((2.0 * M_PI * 3.2544e-6) + 10e-6); // 2pi*R+10um (R = 3.2544um)
    // double internal_length = 2.0 * M_PI * (3.2544e-6 + 10e-6/(2.0*M_PI)); // 2pi*R+10um (R = 3.2544um)
    //double var_factor = 1.01*pi_length;
    // double var_factor = 0;

    // -- Parameterizing components -- //
    for (size_t i = 0; i < N; i++)
    {
        // here is where variation is disabled (0 and uncomment)
        // double _wg_length_variation = var_factor*i;
        double _wg_length = m_ring_length / 2.0;
        // double _wg_length = M_PI * 3.2544e-6 + 10e-6;
        //double _wg_length = 200*100.0*(1550e-9 + 0.1e-9 * i)/(2.0*neff);
        
        //cout << _wg_length_variation << endl;
        cout << wg_top.at(i)->name() << endl;
        wg_top.at(i)->m_length_cm = _wg_length * 100.0;
        wg_top.at(i)->m_neff = m_neff;
        wg_top.at(i)->m_ng = m_ng;
        wg_top.at(i)->m_attenuation_dB_cm = m_loss_db_cm;

        cout << wg_bot.at(i)->name() << endl;
        wg_bot.at(i)->m_length_cm = _wg_length * 100.0;
        wg_bot.at(i)->m_neff = m_neff;
        wg_bot.at(i)->m_ng = m_ng;
        wg_bot.at(i)->m_attenuation_dB_cm = m_loss_db_cm;

        cout << dc.at(i)->name() << endl;
        dc.at(i)->m_dc_through_coupling_power = m_coupling_through;
    }
    dc.at(N)->m_dc_through_coupling_power = m_coupling_through;

    // -- Connecting components -- //
    // Before loop, outer connections on left
    dc.at(0)->p_in1(p_in);
    dc.at(0)->p_out1(p_out_t);
    //p_through.p_in(OUT_THROUGH);

    // Loop, inner connections
    for (size_t i = 0; i < N; i++)
    {
        // Need to take care if odd or even, 
        // as inputs come from different directions
        if (i%2 == 0)
        {
            // If i even, DC(i) input at bottom
            dc.at(i)->p_in2(*S_BL.at(i));
            dc.at(i)->p_out2(*S_TL.at(i));
            // If i even, DC(i+1) input at the top
            dc.at(i+1)->p_in1(*S_TR.at(i));
            dc.at(i+1)->p_out1(*S_BR.at(i));
            // If even, top waveguide(i) is L->R
            wg_top.at(i)->p_in(*S_TL.at(i));
            wg_top.at(i)->p_out(*S_TR.at(i));
            // If even, bottom waveguide(i) is R->L
            wg_bot.at(i)->p_in(*S_BR.at(i));
            wg_bot.at(i)->p_out(*S_BL.at(i));
        }
        else{
            // If i odd, DC(i) input at top
            dc.at(i)->p_in2(*S_TL.at(i));
            dc.at(i)->p_out2(*S_BL.at(i));
            // If i odd, DC(i+1) input at the bottom
            dc.at(i+1)->p_in1(*S_BR.at(i));
            dc.at(i+1)->p_out1(*S_TR.at(i));
            // If odd, top waveguide(i) is R->L
            wg_top.at(i)->p_in(*S_TR.at(i));
            wg_top.at(i)->p_out(*S_TL.at(i));
            // If odd, bottom waveguide(i) is L->R
            wg_bot.at(i)->p_in(*S_BL.at(i));
            wg_bot.at(i)->p_out(*S_BR.at(i));
        }
    }    
    // After loop, outer connections on right
    //pd1.p_readout(PD_OUT);
    dc.at(N)->p_in2(p_add);
    dc.at(N)->p_out2(p_out_d);

    dc.at(0)->m_out1_writer.m_converger = false;
}