function Schematic = Rectifier_circuit(p,t,Subdomains,Circuit,l,nper,~,~)
% 3-phase rectifier circuit example (for generator mode)

Npp=Circuit.Npp;      % number of parallel paths
Rs=Circuit.Rs;
Rs = Npp*Rs;          % parallel path phase resistance
Lsew=Circuit.Lsew;
Lsew = Npp*Lsew;      % parallel path end winding inductance
layout = Circuit.layout;

Roff=10^8;
Ron=10^-6;

[ok_layout, ok_Npp] = ValidateLayout(layout,Npp);
if ~ok_layout
    disp('ValidateLayout: desequencing of parallel path numbering');
    error(' ');
end
if ~ok_Npp
    disp('ValidateLayout: number of parallel paths is not consistent with winding layout table');
    error(' ');
end

Schematic = CircuitCreateSchematic();

%Attatch Coils
Branch = CircuitCreateBranch(0,1);
Branch = CircuitAddCoil(Branch,['coil_a' num2str(1)],'a',Subdomains,Rs,Lsew,1,Npp,1,p,t,l,nper);
Schematic = CircuitAddBranch(Schematic,Branch);

Branch = CircuitCreateBranch(0,2);
Branch = CircuitAddCoil(Branch,['coil_b' num2str(1)],'b',Subdomains,Rs,Lsew,1,Npp,1,p,t,l,nper);
Schematic = CircuitAddBranch(Schematic,Branch);

Branch = CircuitCreateBranch(0,3);
Branch = CircuitAddCoil(Branch,['coil_c' num2str(1)],'c',Subdomains,Rs,Lsew,1,Npp,1,p,t,l,nper);
Schematic = CircuitAddBranch(Schematic,Branch);

Branch = CircuitCreateBranch(0,1);
Branch = CircuitAddCoil(Branch,['coil_a' num2str(2)],'a',Subdomains,Rs,Lsew,2,Npp,1,p,t,l,nper);
Schematic = CircuitAddBranch(Schematic,Branch);

Branch = CircuitCreateBranch(0,2);
Branch = CircuitAddCoil(Branch,['coil_b' num2str(2)],'b',Subdomains,Rs,Lsew,2,Npp,1,p,t,l,nper);
Schematic = CircuitAddBranch(Schematic,Branch);

Branch = CircuitCreateBranch(0,3);
Branch = CircuitAddCoil(Branch,['coil_c' num2str(2)],'c',Subdomains,Rs,Lsew,2,Npp,1,p,t,l,nper);
Schematic = CircuitAddBranch(Schematic,Branch);

%Build Diode Bridge
Branch = CircuitCreateBranch(1,4);
Branch = CircuitAddDiode(Branch,'diode_a1',Roff,Ron,1);
Schematic = CircuitAddBranch(Schematic,Branch);

Branch = CircuitCreateBranch(2,4);
Branch = CircuitAddDiode(Branch,'diode_b1',Roff,Ron,1);
Schematic = CircuitAddBranch(Schematic,Branch);

Branch = CircuitCreateBranch(3,4);
Branch = CircuitAddDiode(Branch,'diode_c1',Roff,Ron,1);
Schematic = CircuitAddBranch(Schematic,Branch);

Branch = CircuitCreateBranch(5,1);
Branch = CircuitAddDiode(Branch,'diode_a2',Roff,Ron,1);
Schematic = CircuitAddBranch(Schematic,Branch);

Branch = CircuitCreateBranch(5,2);
Branch = CircuitAddDiode(Branch,'diode_b2',Roff,Ron,1);
Schematic = CircuitAddBranch(Schematic,Branch);

Branch = CircuitCreateBranch(5,3);
Branch = CircuitAddDiode(Branch,'diode_c2',Roff,Ron,1);
Schematic = CircuitAddBranch(Schematic,Branch);

%Add Resistor
Branch = CircuitCreateBranch(4,5);
Branch = CircuitAddR(Branch,'R1',0.514);
Schematic = CircuitAddBranch(Schematic,Branch);


