CVD/Reactor.pm

filter: Statementstmt 47.0% 40 / 85 Branchbran 12.5% 1 / 8 Conditioncond 28.2% 11 / 39 MC/DCmcdc 0.0% 0 / 20 Subroutinesub 50.0% 11 / 22 Podpod 0.0% 0 / 14 totaltotal 33.5% 63 / 188 CC 24 SCAR 25.0
CC
24
Cov
39%
new
24.3
diffusivity
20.0
thiele_modulus
20.0
CRAP 12.1
« CVD.pm ↑ Summary
1 package Physics::CVD::Reactor;
2 1 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
3 1 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 1 ▶use Carp;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 1 ▶use List::Util qw(sum max min);
Subroutine BEGIN: called CC=1 SCAR=0.0
6  
7 # ═══════════════════════════════════════════════════════════════════════════════
8 # CVD Reactor model
9 #
10 # Defines reactor geometry and operating conditions:
11 # - Horizontal hot-wall tube (LPCVD)
12 # - Showerhead/cold-wall (PECVD, MOCVD)
13 # - Batch vs single-wafer
14 # - Gas flow rates, residence time, Damköhler number
15 # ═══════════════════════════════════════════════════════════════════════════════
16  
17 1 ▶use constant KB => 1.380649e-23;
Subroutine BEGIN: called CC=1 SCAR=0.0
18 1 ▶use constant R_GAS => 8.314462;
Subroutine BEGIN: called CC=1 SCAR=0.0
19 1 ▶use constant PI => 3.14159265358979;
Subroutine BEGIN: called CC=1 SCAR=0.0
20  
21 1 ▶sub new {
Subroutine new: called CC=12 SCAR=31.9
Pod undocumented
22 1 my ($class, %opts) = @_;
23 my $self = bless {
24 type => $opts{type} // 'lpcvd_tube', # lpcvd_tube, pecvd, mocvd
25 temperature => $opts{temperature} // 700,
26 pressure => $opts{pressure} // 100, # Pa
27 verbose => $opts{verbose} // 0,
28 # Geometry
29 length => $opts{length} // 1.0, # m (tube length)
30 diameter => $opts{diameter} // 0.15, # m (tube diameter)
31 gap => $opts{gap} // 0.02, # m (showerhead gap)
32 wafer_diameter => $opts{wafer_diameter} // 0.3, # m (300mm wafer)
33 # Gas flow
34 total_flow => $opts{total_flow} // 100, # sccm
35 carrier_gas => $opts{carrier_gas} // 'N2',
36 gases => $opts{gases} // {}, # {name => flow_sccm}
37 1 ▶ }, $class;
Condition50%11/22
$opts{"type"} // "lpcvd_tube"
l!l
01
$opts{"temperature"} // 700
l!l
10
$opts{"pressure"} // 100
l!l
10
$opts{"verbose"} // 0
l!l
01
$opts{"length"} // 1
l!l
01
$opts{"diameter"} // "0.15"
l!l
01
$opts{"gap"} // "0.02"
l!l
01
$opts{"wafer_diameter"} // "0.3"
l!l
01
$opts{"total_flow"} // 100
l!l
10
$opts{"carrier_gas"} // "N2"
l!l
01
$opts{"gases"} // {}
l!l
01
MC/DC0%0/1
$opts{"type"} // "lpcvd_tube"
$opts{"type"}
MC/DC0%0/1
$opts{"temperature"} // 700
$opts{"temperature"}
MC/DC0%0/1
$opts{"pressure"} // 100
$opts{"pressure"}
MC/DC0%0/1
$opts{"verbose"} // 0
$opts{"verbose"}
MC/DC0%0/1
$opts{"length"} // 1
$opts{"length"}
MC/DC0%0/1
$opts{"diameter"} // "0.15"
$opts{"diameter"}
MC/DC0%0/1
$opts{"gap"} // "0.02"
$opts{"gap"}
MC/DC0%0/1
$opts{"wafer_diameter"} // "0.3"
$opts{"wafer_diameter"}
MC/DC0%0/1
$opts{"total_flow"} // 100
$opts{"total_flow"}
MC/DC0%0/1
$opts{"carrier_gas"} // "N2"
$opts{"carrier_gas"}
MC/DC0%0/1
$opts{"gases"} // {}
$opts{"gases"}
Truth table50%1/2
A
A= $opts{"type"}
Aresult
11
00
Truth table50%1/2
A
A= $opts{"temperature"}
Aresult
11
00
Truth table50%1/2
A
A= $opts{"pressure"}
Aresult
11
00
Truth table50%1/2
A
A= $opts{"verbose"}
Aresult
11
00
Truth table50%1/2
A
A= $opts{"length"}
Aresult
11
00
Truth table50%1/2
A
A= $opts{"diameter"}
Aresult
11
00
Truth table50%1/2
A
A= $opts{"gap"}
Aresult
11
00
Truth table50%1/2
A
A= $opts{"wafer_diameter"}
Aresult
11
00
Truth table50%1/2
A
A= $opts{"total_flow"}
Aresult
11
00
Truth table50%1/2
A
A= $opts{"carrier_gas"}
Aresult
11
00
Truth table50%1/2
A
A= $opts{"gases"}
Aresult
11
00
38 1 return $self;
39 }
40  
41 # Gas velocity in tube (m/s)
42 2 ▶sub gas_velocity {
Subroutine gas_velocity: called CC=1 SCAR=0.0
Pod undocumented
43 2 my ($self) = @_;
44 2 my $T = $self->{temperature};
45 2 my $P = $self->{pressure};
46 2 my $flow_m3s = $self->{total_flow} * 1e-6 / 60.0; # sccm -> m³/s at STP
47 # Correct for actual T,P
48 2 $flow_m3s *= ($T / 273.15) * (101325.0 / $P);
49 2 my $area = PI() * ($self->{diameter}/2)**2;
50 2 return $flow_m3s / $area;
51 }
52  
53 # Residence time (seconds)
54 1 ▶sub residence_time {
Subroutine residence_time: called CC=2 SCAR=7.1
Pod undocumented
55 1 my ($self) = @_;
56 1 my $v = $self->gas_velocity;
57 1 ▶ return ($v > 0) ? $self->{length} / $v : 0;
Branch: 1 branch
BranchTrueFalseTotal
$v > 0 ? : 1 0 1
58 }
59  
60 # Reynolds number
61 0 ▶sub reynolds_number {
Subroutine reynolds_number: not called CC=2 SCAR=17.9
Pod undocumented
62 0 my ($self) = @_;
63 0 my $v = $self->gas_velocity;
64 0 my $rho = $self->gas_density;
65 0 my $mu = $self->gas_viscosity;
66 0 ▶ return ($mu > 0) ? $rho * $v * $self->{diameter} / $mu : 0;
Branch: 1 branch
BranchTrueFalseTotal
$mu > 0 ? : 0 0 0
67 }
68  
69 # Gas density (kg/m³) using ideal gas
70 0 ▶sub gas_density {
Subroutine gas_density: not called CC=1 SCAR=6.9
Pod undocumented
71 0 my ($self) = @_;
72 0 my $M = $self->_carrier_molar_mass;
73 0 return $self->{pressure} * $M / (R_GAS * $self->{temperature});
74 }
75  
76 # Gas viscosity (Pa·s) — Sutherland approximation for N₂
77 0 ▶sub gas_viscosity {
Subroutine gas_viscosity: not called CC=1 SCAR=6.9
Pod undocumented
78 0 my ($self) = @_;
79 0 my $T = $self->{temperature};
80 # Sutherland: μ = μ₀(T/T₀)^(3/2) × (T₀+S)/(T+S)
81 0 my $mu0 = 1.76e-5; # Pa·s at 300K
82 0 my $T0 = 300;
83 0 my $S = 111; # K (Sutherland constant for N₂)
84 0 return $mu0 * ($T/$T0)**1.5 * ($T0 + $S) / ($T + $S);
85 }
86  
87 # Mean free path (m)
88 1 ▶sub mean_free_path {
Subroutine mean_free_path: called CC=1 SCAR=0.0
Pod undocumented
89 1 my ($self) = @_;
90 1 my $T = $self->{temperature};
91 1 my $P = $self->{pressure};
92 1 my $d = 3.7e-10; # molecular diameter N₂ (m)
93 1 return KB * $T / (sqrt(2) * PI() * $d**2 * $P);
94 }
95  
96 # Knudsen number (Kn = λ/L)
97 0 ▶sub knudsen_number {
Subroutine knudsen_number: not called CC=2 SCAR=17.9
Pod undocumented
98 0 my ($self) = @_;
99 0 ▶ my $L = ($self->{type} =~ /tube/) ? $self->{diameter} : $self->{gap};
Branch: 1 branch
BranchTrueFalseTotal
$self->{'type'} =~ /tube/ ? : 0 0 0
100 0 return $self->mean_free_path / $L;
101 }
102  
103 # Damköhler number (Da = reaction rate / mass transfer rate)
104 0 ▶sub damkohler_number {
Subroutine damkohler_number: not called CC=3 SCAR=24.8
Pod undocumented
105 0 my ($self, %opts) = @_;
106 0 ▶ my $k_s = $opts{surface_rate} // 1e-2; # cm/s (surface reaction rate)
Condition0%0/2
$opts{"surface_rate"} // "0.01"
l!l
00
MC/DC0%0/1
$opts{"surface_rate"} // "0.01"
$opts{"surface_rate"}
Truth table0%0/2
A
A= $opts{"surface_rate"}
Aresult
11
00
107 0 my $D = $self->diffusivity(%opts); # cm²/s
108 0 ▶ my $L = ($self->{type} =~ /tube/) ? $self->{diameter} : $self->{gap};
Branch: 1 branch
BranchTrueFalseTotal
$self->{'type'} =~ /tube/ ? : 0 0 0
109 0 return $k_s * $L * 100 / $D; # dimensionless
110 }
111  
112 # Binary gas diffusivity (cm²/s) — Chapman-Enskog
113 0 ▶sub diffusivity {
Subroutine diffusivity: not called CC=4 SCAR=30.0
Pod undocumented
114 0 my ($self, %opts) = @_;
115 0 my $T = $self->{temperature};
116 0 my $P = $self->{pressure} / 101325.0; # Pa -> atm
117 0 ▶ my $M1 = $opts{mass1} // 28; # carrier (N₂)
Condition0%0/2
$opts{"mass1"} // 28
l!l
00
MC/DC0%0/1
$opts{"mass1"} // 28
$opts{"mass1"}
Truth table0%0/2
A
A= $opts{"mass1"}
Aresult
11
00
118 0 ▶ my $M2 = $opts{mass2} // 44; # precursor
Condition0%0/2
$opts{"mass2"} // 44
l!l
00
MC/DC0%0/1
$opts{"mass2"} // 44
$opts{"mass2"}
Truth table0%0/2
A
A= $opts{"mass2"}
Aresult
11
00
119 0 ▶ my $sigma = $opts{sigma} // 4.0; # Angstrom, collision diameter
Condition0%0/2
$opts{"sigma"} // 4
l!l
00
MC/DC0%0/1
$opts{"sigma"} // 4
$opts{"sigma"}
Truth table0%0/2
A
A= $opts{"sigma"}
Aresult
11
00
120 0 my $Omega = 1.0; # collision integral (simplification)
121  
122 # D₁₂ = 0.00186 × T^(3/2) × sqrt(1/M₁ + 1/M₂) / (P × σ² × Ω)
123 0 my $D = 0.00186 * $T**1.5 * sqrt(1/$M1 + 1/$M2) /
124 ($P * $sigma**2 * $Omega);
125 0 return $D; # cm²/s
126 }
127  
128 # Thiele modulus for feature-scale transport
129 0 ▶sub thiele_modulus {
Subroutine thiele_modulus: not called CC=4 SCAR=30.0
Pod undocumented
130 0 my ($self, %opts) = @_;
131 0 ▶ my $L = $opts{feature_depth} // 1e-4; # cm (1 μm trench)
Condition0%0/2
$opts{"feature_depth"} // "0.0001"
l!l
00
MC/DC0%0/1
$opts{"feature_depth"} // "0.0001"
$opts{"feature_depth"}
Truth table0%0/2
A
A= $opts{"feature_depth"}
Aresult
11
00
132 0 ▶ my $D = $opts{diffusivity} // $self->diffusivity(%opts);
Condition0%0/3
$opts{"diffusivity"} // $self->diffusivity(%opts)
l!l&&r!l&&!r
000
MC/DC0%0/2
$opts{"diffusivity"} // $self->diffusivity(%opts)
$opts{"diffusivity"} $self->diffusivity(%opts)
Truth table0%0/3
A // B
A= $opts{"diffusivity"}B= $self->diffusivity(%opts)
ABresult
1X1
011
000
133 0 ▶ my $k_s = $opts{surface_rate} // 0.01; # cm/s
Condition0%0/2
$opts{"surface_rate"} // "0.01"
l!l
00
MC/DC0%0/1
$opts{"surface_rate"} // "0.01"
$opts{"surface_rate"}
Truth table0%0/2
A
A= $opts{"surface_rate"}
Aresult
11
00
134 0 return $L * sqrt($k_s / $D);
135 }
136  
137 # Step coverage estimate for a trench
138 0 ▶sub step_coverage {
Subroutine step_coverage: not called CC=1 SCAR=6.9
Pod undocumented
139 0 my ($self, %opts) = @_;
140 0 my $phi = $self->thiele_modulus(%opts);
141 # Simplified: SC ≈ 1/cosh(φ) for first-order reaction in trench
142 0 return 1.0 / cosh($phi);
143 }
144  
145 0 ▶sub _carrier_molar_mass {
Subroutine _carrier_molar_mass: not called CC=2 SCAR=17.9
146 0 my ($self) = @_;
147 0 my %masses = (N2 => 0.028, Ar => 0.040, H2 => 0.002, He => 0.004);
148 0 ▶ return $masses{$self->{carrier_gas}} // 0.028;
Condition0%0/2
$masses{$self->{"carrier_gas"}} // "0.028"
l!l
00
MC/DC0%0/1
$masses{$self->{"carrier_gas"}} // "0.028"
$masses{$self->{"carrier_gas"}}
Truth table0%0/2
A
A= $masses{$self->{"carrier_gas"}}
Aresult
11
00
149 }
150  
151 0 ▶sub summary {
Subroutine summary: not called CC=1 SCAR=6.9
Pod undocumented
152 0 my ($self) = @_;
153 return {
154 type => $self->{type},
155 temperature => $self->{temperature},
156 pressure => $self->{pressure},
157 0 gas_velocity => $self->gas_velocity,
158 residence_time => $self->residence_time,
159 reynolds => $self->reynolds_number,
160 knudsen => $self->knudsen_number,
161 mean_free_path => $self->mean_free_path,
162 };
163 }
164  
165 # Helper for cosh
166 0 ▶sub cosh { return (exp($_[0]) + exp(-$_[0])) / 2.0 }
Subroutine cosh: not called CC=1 SCAR=6.9
Pod undocumented
167  
168 1 1;
« CVD.pm ↑ Summary