CVD/Interface/Cantera.pm

filter: Statementstmt 32.5% 13 / 40 Branchbran 0.0% 0 / 8 Conditioncond 0.0% 0 / 10 MC/DCmcdc 0.0% 0 / 5 Subroutinesub 50.0% 4 / 8 Podpod 0.0% 0 / 4 totaltotal 22.6% 17 / 75 CC 10 SCAR 29.2
CC
10
Cov
22%
generate_reactor_script
42.0
new
12.0
generate_sio2_mechanism
6.0
CRAP 18.6
« CVD/KMC.pm ↑ Summary CVD/Interface/OpenFOAM.pm »
1 package Physics::CVD::Interface::Cantera;
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 File::Path qw(make_path);
Subroutine BEGIN: called CC=1 SCAR=0.0
6  
7 # ═══════════════════════════════════════════════════════════════════════════════
8 # Cantera interface for detailed gas-phase and surface chemistry
9 #
10 # Generates:
11 # - CTI/YAML mechanism files for CVD chemistry
12 # - Python scripts for reactor simulations via Cantera
13 # - Surface site density and coverage calculations
14 # ═══════════════════════════════════════════════════════════════════════════════
15  
16 0 ▶sub new {
Subroutine new: not called CC=3 SCAR=24.8
Pod undocumented
17 0 my ($class, %opts) = @_;
18 my $self = bless {
19 0 ▶ work_dir => $opts{work_dir} // './cantera_cvd',
Condition0%0/2
$opts{"work_dir"} // "./cantera_cvd"
l!l
00
MC/DC0%0/1
$opts{"work_dir"} // "./cantera_cvd"
$opts{"work_dir"}
Truth table0%0/2
A
A= $opts{"work_dir"}
Aresult
11
00
20 }, $class;
21 0 ▶ make_path($self->{work_dir}) unless -d $self->{work_dir};
Branch: 1 branch
BranchTrueFalseTotal
unless -d $self->{"work_dir"} 0 0 0
22 0 return $self;
23 }
24  
25 # Generate a Cantera YAML mechanism file for TEOS/O₂ → SiO₂
26 0 ▶sub generate_sio2_mechanism {
Subroutine generate_sio2_mechanism: not called CC=2 SCAR=17.9
Pod undocumented
27 0 my ($self, %opts) = @_;
28 0 my $filename = "$self->{work_dir}/sio2_cvd.yaml";
29  
30 0 ▶ open my $fh, '>', $filename or croak "Cannot write $filename: $!";
Branch: 1 branch
BranchTrueFalseTotal
open my $fh, ">", $filename or croak("Cannot write ${filename}: $!") 0 0 0
31 0 print $fh <<'EOF';
32 description: |-
33 TEOS CVD mechanism for SiO2 deposition
34 Simplified mechanism based on Coltrin et al. (1998)
35  
36 units: {length: cm, quantity: mol, activation-energy: kJ/mol}
37  
38 phases:
39 - name: gas
40 thermo: ideal-gas
41 species: [TEOS, Si(OC2H5)4, Si(OH)4, SiO2_g, O2, H2O, C2H4, CO2, N2]
42 kinetics: gas
43 reactions: [gas-reactions]
44 transport: mixture-averaged
45  
46 - name: surface
47 thermo: ideal-surface
48 species: [Si_s, O_s, OH_s, empty_s]
49 kinetics: surface
50 reactions: [surface-reactions]
51 site-density: 1.5e-9 # mol/cm^2
52  
53 species:
54 - name: TEOS
55 composition: {Si: 1, O: 4, C: 8, H: 20}
56 thermo:
57 model: constant-cp
58 T0: 700 K
59 h0: -1300 kJ/mol
60 s0: 500 J/mol/K
61 cp0: 300 J/mol/K
62 - name: O2
63 composition: {O: 2}
64 thermo:
65 model: constant-cp
66 T0: 700 K
67 h0: 0 kJ/mol
68 s0: 205 J/mol/K
69 cp0: 30 J/mol/K
70 - name: SiO2_g
71 composition: {Si: 1, O: 2}
72 thermo:
73 model: constant-cp
74 T0: 700 K
75 h0: -910 kJ/mol
76 s0: 228 J/mol/K
77 cp0: 44 J/mol/K
78 - name: H2O
79 composition: {H: 2, O: 1}
80 thermo:
81 model: constant-cp
82 T0: 700 K
83 h0: -242 kJ/mol
84 s0: 189 J/mol/K
85 cp0: 34 J/mol/K
86 - name: N2
87 composition: {N: 2}
88 thermo:
89 model: constant-cp
90 T0: 700 K
91 h0: 0 kJ/mol
92 s0: 192 J/mol/K
93 cp0: 29 J/mol/K
94  
95 gas-reactions:
96 - equation: TEOS => SiO2_g + 4 C2H4 + 2 H2O
97 rate-constant: {A: 1.0e+15, b: 0, Ea: 280 kJ/mol}
98  
99 surface-reactions:
100 - equation: TEOS + empty_s => Si_s + 4 C2H4 + 2 H2O
101 sticking-coefficient: {A: 0.05, b: 0, Ea: 50 kJ/mol}
102 - equation: O2 + 2 Si_s => 2 O_s + 2 empty_s
103 rate-constant: {A: 1.0e+13, b: 0, Ea: 100 kJ/mol}
104 EOF
105 0 close $fh;
106 0 return $filename;
107 }
108  
109 # Generate a Cantera YAML for Si₃N₄ LPCVD (DCS + NH₃)
110 0 ▶sub generate_si3n4_mechanism {
Subroutine generate_si3n4_mechanism: not called CC=2 SCAR=17.9
Pod undocumented
111 0 my ($self, %opts) = @_;
112 0 my $filename = "$self->{work_dir}/si3n4_cvd.yaml";
113  
114 0 ▶ open my $fh, '>', $filename or croak "Cannot write $filename: $!";
Branch: 1 branch
BranchTrueFalseTotal
open my $fh, ">", $filename or croak("Cannot write ${filename}: $!") 0 0 0
115 0 print $fh <<'EOF';
116 description: |-
117 Si3N4 LPCVD mechanism (DCS + NH3)
118 Based on Coltrin & Ho (2000), simplified
119  
120 units: {length: cm, quantity: mol, activation-energy: kJ/mol}
121  
122 phases:
123 - name: gas
124 thermo: ideal-gas
125 species: [SiH2Cl2, NH3, SiCl2, HCl, H2, N2, SiH2NH]
126 kinetics: gas
127 reactions: [gas-reactions]
128  
129 - name: surface
130 thermo: ideal-surface
131 species: [Si_s, N_s, NH_s, Cl_s, empty_s]
132 kinetics: surface
133 reactions: [surface-reactions]
134 site-density: 1.2e-9
135  
136 species:
137 - name: SiH2Cl2
138 composition: {Si: 1, H: 2, Cl: 2}
139 thermo:
140 model: constant-cp
141 T0: 800 K
142 h0: -320 kJ/mol
143 s0: 286 J/mol/K
144 cp0: 70 J/mol/K
145 - name: NH3
146 composition: {N: 1, H: 3}
147 thermo:
148 model: constant-cp
149 T0: 800 K
150 h0: -46 kJ/mol
151 s0: 193 J/mol/K
152 cp0: 36 J/mol/K
153 - name: SiCl2
154 composition: {Si: 1, Cl: 2}
155 thermo:
156 model: constant-cp
157 T0: 800 K
158 h0: -168 kJ/mol
159 s0: 281 J/mol/K
160 cp0: 52 J/mol/K
161 - name: HCl
162 composition: {H: 1, Cl: 1}
163 thermo:
164 model: constant-cp
165 T0: 800 K
166 h0: -92 kJ/mol
167 s0: 187 J/mol/K
168 cp0: 29 J/mol/K
169 - name: H2
170 composition: {H: 2}
171 thermo:
172 model: constant-cp
173 T0: 800 K
174 h0: 0 kJ/mol
175 s0: 131 J/mol/K
176 cp0: 29 J/mol/K
177 - name: N2
178 composition: {N: 2}
179 thermo:
180 model: constant-cp
181 T0: 800 K
182 h0: 0 kJ/mol
183 s0: 192 J/mol/K
184 cp0: 29 J/mol/K
185  
186 gas-reactions:
187 - equation: SiH2Cl2 => SiCl2 + H2
188 rate-constant: {A: 5.0e+13, b: 0, Ea: 240 kJ/mol}
189 - equation: SiCl2 + NH3 => SiH2NH + 2 HCl
190 rate-constant: {A: 1.0e+12, b: 0, Ea: 100 kJ/mol}
191  
192 surface-reactions:
193 - equation: SiCl2 + empty_s => Si_s + 2 HCl
194 sticking-coefficient: {A: 0.3, b: 0, Ea: 20 kJ/mol}
195 - equation: NH3 + Si_s => NH_s + 1.5 H2
196 sticking-coefficient: {A: 0.1, b: 0, Ea: 30 kJ/mol}
197 - equation: NH_s + Si_s => N_s + empty_s
198 rate-constant: {A: 1.0e+13, b: 0, Ea: 150 kJ/mol}
199 EOF
200 0 close $fh;
201 0 return $filename;
202 }
203  
204 # Generate Python script that uses Cantera to simulate a CVD reactor
205 0 ▶sub generate_reactor_script {
Subroutine generate_reactor_script: not called CC=6 SCAR=37.4
Pod undocumented
206 0 my ($self, %opts) = @_;
207 0 ▶ my $mech = $opts{mechanism} // 'sio2_cvd.yaml';
Condition0%0/2
$opts{"mechanism"} // "sio2_cvd.yaml"
l!l
00
MC/DC0%0/1
$opts{"mechanism"} // "sio2_cvd.yaml"
$opts{"mechanism"}
Truth table0%0/2
A
A= $opts{"mechanism"}
Aresult
11
00
208 0 ▶ my $T = $opts{temperature} // 700;
Condition0%0/2
$opts{"temperature"} // 700
l!l
00
MC/DC0%0/1
$opts{"temperature"} // 700
$opts{"temperature"}
Truth table0%0/2
A
A= $opts{"temperature"}
Aresult
11
00
209 0 ▶ my $P = $opts{pressure} // 100;
Condition0%0/2
$opts{"pressure"} // 100
l!l
00
MC/DC0%0/1
$opts{"pressure"} // 100
$opts{"pressure"}
Truth table0%0/2
A
A= $opts{"pressure"}
Aresult
11
00
210 0 ▶ my $duration = $opts{duration} // 60;
Condition0%0/2
$opts{"duration"} // 60
l!l
00
MC/DC0%0/1
$opts{"duration"} // 60
$opts{"duration"}
Truth table0%0/2
A
A= $opts{"duration"}
Aresult
11
00
211  
212 0 my $filename = "$self->{work_dir}/run_reactor.py";
213 0 ▶ open my $fh, '>', $filename or croak "Cannot write $filename: $!";
Branch: 1 branch
BranchTrueFalseTotal
open my $fh, ">", $filename or croak("Cannot write ${filename}: $!") 0 0 0
214 0 printf $fh <<'EOF', $mech, $T, $P, $duration;
215 #!/usr/bin/env python3
216 """CVD reactor simulation using Cantera — generated by Physics::CVD"""
217 import cantera as ct
218 import numpy as np
219  
220 # Load mechanism
221 gas = ct.Solution('%s', 'gas')
222 surf = ct.Interface('%s', 'surface', [gas])
223  
224 # Set conditions
225 T = %g # K
226 P = %g # Pa
227 gas.TPX = T, P, 'TEOS:0.05, O2:0.2, N2:0.75'
228 surf.TP = T, P
229  
230 # Create reactor
231 reactor = ct.IdealGasReactor(gas)
232 reactor.volume = 1e-3 # m³
233  
234 # Surface reactor
235 rsurf = ct.ReactorSurface(surf, reactor, A=0.07) # 300mm wafer area
236  
237 # Simulation
238 sim = ct.ReactorNet([reactor])
239 duration = %g # seconds
240  
241 times = np.linspace(0, duration, 200)
242 coverages = []
243 growth_rates = []
244  
245 for t in times:
246 sim.advance(t)
247 coverages.append(surf.coverages.copy())
248 # Growth rate from surface production rate of SiO2
249 growth_rates.append(surf.net_production_rates)
250  
251 coverages = np.array(coverages)
252 print(f"Final temperature: {reactor.T:.1f} K")
253 print(f"Final pressure: {reactor.thermo.P:.1f} Pa")
254 print(f"Surface coverages: {dict(zip(surf.species_names, surf.coverages))}")
255 print(f"Simulation complete: {duration}s simulated")
256 EOF
257 0 close $fh;
258 0 chmod 0755, $filename;
259 0 return $filename;
260 }
261  
262 1 1;
« CVD/KMC.pm ↑ Summary CVD/Interface/OpenFOAM.pm »