mirror of
https://github.com/Cantera/cantera.git
synced 2025-02-25 18:55:29 -06:00
Migrate CSTR example from Jupyter
Co-authored-by: Santosh Shanbhogue <santosh.shanbhogue@gmail.com>
This commit is contained in:
committed by
Ingmar Schoegl
parent
84b9c9c3a7
commit
b39c64aee8
163
doc/sphinx/_static/images/samples/stirred-reactor-network.svg
Normal file
163
doc/sphinx/_static/images/samples/stirred-reactor-network.svg
Normal file
@@ -0,0 +1,163 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<svg id="Layer_1" data-name="Layer 1" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 1264.92 546.1">
|
||||
<defs>
|
||||
<style>
|
||||
.cls-1 {
|
||||
stroke: #1b719c;
|
||||
stroke-width: 7px;
|
||||
}
|
||||
|
||||
.cls-1, .cls-2, .cls-3, .cls-4, .cls-5, .cls-6, .cls-7, .cls-8, .cls-9, .cls-10 {
|
||||
fill: none;
|
||||
}
|
||||
|
||||
.cls-1, .cls-5 {
|
||||
stroke-linejoin: round;
|
||||
}
|
||||
|
||||
.cls-11 {
|
||||
stroke: #363;
|
||||
}
|
||||
|
||||
.cls-11, .cls-12, .cls-2, .cls-3, .cls-4, .cls-6, .cls-7, .cls-8, .cls-13, .cls-9, .cls-10 {
|
||||
stroke-miterlimit: 10;
|
||||
}
|
||||
|
||||
.cls-11, .cls-14 {
|
||||
fill: #fff1cc;
|
||||
}
|
||||
|
||||
.cls-11, .cls-10 {
|
||||
stroke-width: 3px;
|
||||
}
|
||||
|
||||
.cls-15 {
|
||||
letter-spacing: -.03em;
|
||||
}
|
||||
|
||||
.cls-12 {
|
||||
fill: #428737;
|
||||
}
|
||||
|
||||
.cls-12, .cls-2, .cls-7, .cls-13 {
|
||||
stroke-width: 2px;
|
||||
}
|
||||
|
||||
.cls-12, .cls-5, .cls-8, .cls-13, .cls-10 {
|
||||
stroke: #000;
|
||||
}
|
||||
|
||||
.cls-16, .cls-17 {
|
||||
fill: #000;
|
||||
}
|
||||
|
||||
.cls-16, .cls-14 {
|
||||
stroke-width: 0px;
|
||||
}
|
||||
|
||||
.cls-2 {
|
||||
stroke-linecap: square;
|
||||
}
|
||||
|
||||
.cls-2, .cls-7 {
|
||||
stroke: #39c;
|
||||
}
|
||||
|
||||
.cls-3 {
|
||||
stroke-dasharray: 0 0 2 3.01;
|
||||
}
|
||||
|
||||
.cls-3, .cls-4, .cls-9 {
|
||||
stroke: #8c681a;
|
||||
stroke-width: 1.5px;
|
||||
}
|
||||
|
||||
.cls-4 {
|
||||
stroke-dasharray: 0 0 1.99 2.98;
|
||||
}
|
||||
|
||||
.cls-17 {
|
||||
font-family: SegoeUI, 'Segoe UI';
|
||||
font-size: 30px;
|
||||
}
|
||||
|
||||
.cls-5, .cls-8 {
|
||||
stroke-width: 5px;
|
||||
}
|
||||
|
||||
.cls-6 {
|
||||
stroke: #737373;
|
||||
stroke-width: 6px;
|
||||
}
|
||||
|
||||
.cls-13 {
|
||||
fill: #df9d00;
|
||||
}
|
||||
</style>
|
||||
</defs>
|
||||
<polyline class="cls-8" points="382.26 231.22 192.65 231.22 192.65 35.71 81.46 35.71"/>
|
||||
<line class="cls-8" x1="743.53" y1="339.95" x2="810.78" y2="339.95"/>
|
||||
<path class="cls-2" d="M382.26,223.46c27.97-.04,55.94-.04,83.91,0v-49.67h227.91v159.16h49.45"/>
|
||||
<polyline class="cls-7" points="743.53 332.96 743.53 345.46 694.47 345.46 694.47 389.42 465.86 389.42 465.86 237.89 382.26 237.89 382.26 223.46"/>
|
||||
<g>
|
||||
<rect class="cls-14" x="472.63" y="180.02" width="215.48" height="203.73"/>
|
||||
<g>
|
||||
<polyline class="cls-9" points="472.63 181.02 472.63 180.02 473.63 180.02"/>
|
||||
<line class="cls-3" x1="476.63" y1="180.02" x2="685.6" y2="180.02"/>
|
||||
<polyline class="cls-9" points="687.11 180.02 688.11 180.02 688.11 181.02"/>
|
||||
<line class="cls-4" x1="688.11" y1="184" x2="688.11" y2="381.26"/>
|
||||
<polyline class="cls-9" points="688.11 382.76 688.11 383.76 687.11 383.76"/>
|
||||
<line class="cls-3" x1="684.1" y1="383.76" x2="475.13" y2="383.76"/>
|
||||
<polyline class="cls-9" points="473.63 383.76 472.63 383.76 472.63 382.76"/>
|
||||
<line class="cls-4" x1="472.63" y1="379.77" x2="472.63" y2="182.51"/>
|
||||
</g>
|
||||
</g>
|
||||
<g>
|
||||
<polyline class="cls-11" points="537.46 99.6 578.78 99.6 619.82 99.6"/>
|
||||
<line class="cls-11" x1="579.96" y1="299.96" x2="579.96" y2="99.6"/>
|
||||
</g>
|
||||
<ellipse class="cls-11" cx="536.43" cy="299.96" rx="43.52" ry="11.14"/>
|
||||
<ellipse class="cls-11" cx="623.48" cy="299.7" rx="43.52" ry="11.14"/>
|
||||
<g>
|
||||
<path class="cls-10" d="M618.01,204.24c-18.57,0-33.85,1.27-45.06,2.59-4.08.48-14.17,1.73-26.16,6.47-15.99,6.33-18.45,12.17-19.17,14.5-.19.62-1.53,5.26.52,10.1,2.43,5.74,8.19,8.37,14.24,10.62,17.59,6.54,32.63,8.03,32.63,8.03,6.56.65,14.5,1.24,23.61,1.51"/>
|
||||
<polygon class="cls-16" points="594.42 264.05 617.23 258.11 594.51 251.85 594.42 264.05"/>
|
||||
</g>
|
||||
<path class="cls-11" d="M579.96,189.47v38.07"/>
|
||||
<polygon class="cls-12" points="61.34 42.37 35.45 64.03 35.45 496.73 122.98 496.73 122.98 64.51 99.16 42.37 61.34 42.37"/>
|
||||
<g>
|
||||
<polyline class="cls-6" points="35.45 3 79.22 3 122.98 3"/>
|
||||
<line class="cls-6" x1="79.22" y1="42.37" x2="79.22" y2="3"/>
|
||||
</g>
|
||||
<g>
|
||||
<polyline class="cls-6" points="1127.62 14.08 1171.39 14.08 1215.16 14.08"/>
|
||||
<line class="cls-6" x1="1171.39" y1="53.45" x2="1171.39" y2="14.08"/>
|
||||
</g>
|
||||
<polygon class="cls-1" points="812.48 286.86 812.48 360.21 916.48 286.86 916.48 360.21 812.48 286.86"/>
|
||||
<polygon class="cls-12" points="1153.52 53.45 1127.62 74.58 1127.62 496.73 1215.16 496.73 1215.16 75.05 1191.33 53.45 1153.52 53.45"/>
|
||||
<polygon class="cls-13" points="245.23 264.06 245.23 169.01 297.55 169.01 320.86 192.32 320.86 264.06 245.23 264.06"/>
|
||||
<text class="cls-17" transform="translate(0 533.76)"><tspan x="0" y="0">Mixture tank</tspan></text>
|
||||
<g>
|
||||
<path class="cls-16" d="M246.17,310.84h-2.45v-14.09c0-1.11.07-2.48.21-4.09h-.06c-.23.95-.44,1.63-.63,2.04l-7.18,16.14h-1.2l-7.16-16.03c-.21-.47-.42-1.19-.63-2.15h-.06c.08.84.12,2.21.12,4.12v14.06h-2.37v-21.01h3.25l6.45,14.65c.5,1.12.82,1.96.97,2.52h.09c.42-1.15.76-2.01,1.01-2.58l6.58-14.59h3.08v21.01Z"/>
|
||||
<path class="cls-16" d="M262.1,310.84h-2.4v-2.34h-.06c-1.04,1.8-2.58,2.7-4.61,2.7-1.49,0-2.66-.4-3.51-1.19s-1.27-1.84-1.27-3.15c0-2.8,1.65-4.43,4.95-4.89l4.5-.63c0-2.55-1.03-3.82-3.09-3.82-1.81,0-3.44.62-4.89,1.85v-2.46c1.47-.94,3.17-1.41,5.1-1.41,3.53,0,5.29,1.87,5.29,5.6v9.76ZM259.7,303.25l-3.62.5c-1.11.16-1.95.43-2.52.83-.57.39-.85,1.1-.85,2.1,0,.73.26,1.33.78,1.79s1.22.7,2.09.7c1.19,0,2.18-.42,2.95-1.25.78-.84,1.16-1.89,1.16-3.17v-1.49Z"/>
|
||||
<path class="cls-16" d="M265.72,310.29v-2.58c1.31.97,2.75,1.45,4.32,1.45,2.11,0,3.16-.7,3.16-2.11,0-.4-.09-.74-.27-1.02-.18-.28-.42-.53-.73-.74s-.67-.41-1.08-.58-.86-.35-1.34-.54c-.66-.26-1.25-.53-1.75-.8-.5-.27-.92-.57-1.26-.91-.34-.34-.59-.72-.76-1.15s-.26-.93-.26-1.51c0-.7.16-1.33.48-1.87.32-.54.75-1,1.29-1.36.54-.37,1.15-.64,1.84-.83s1.4-.28,2.13-.28c1.3,0,2.46.22,3.49.67v2.43c-1.1-.72-2.37-1.08-3.81-1.08-.45,0-.85.05-1.22.15-.36.1-.67.25-.93.43s-.46.41-.6.67c-.14.26-.21.54-.21.86,0,.39.07.72.21.98s.35.5.62.7.61.39,1,.56.83.35,1.33.54c.66.25,1.26.52,1.79.78.53.27.98.57,1.35.91.37.34.66.73.86,1.17s.3.96.3,1.57c0,.74-.16,1.39-.49,1.93s-.76,1-1.31,1.36-1.18.63-1.89.81-1.46.26-2.24.26c-1.54,0-2.88-.3-4.01-.89Z"/>
|
||||
<path class="cls-16" d="M278.45,310.29v-2.58c1.31.97,2.75,1.45,4.32,1.45,2.11,0,3.16-.7,3.16-2.11,0-.4-.09-.74-.27-1.02-.18-.28-.42-.53-.73-.74s-.67-.41-1.08-.58-.86-.35-1.34-.54c-.66-.26-1.25-.53-1.75-.8-.5-.27-.92-.57-1.26-.91-.34-.34-.59-.72-.76-1.15s-.26-.93-.26-1.51c0-.7.16-1.33.48-1.87.32-.54.75-1,1.29-1.36.54-.37,1.15-.64,1.84-.83s1.4-.28,2.13-.28c1.3,0,2.46.22,3.49.67v2.43c-1.1-.72-2.37-1.08-3.81-1.08-.45,0-.85.05-1.22.15-.36.1-.67.25-.93.43s-.46.41-.6.67c-.14.26-.21.54-.21.86,0,.39.07.72.21.98s.35.5.62.7.61.39,1,.56.83.35,1.33.54c.66.25,1.26.52,1.79.78.53.27.98.57,1.35.91.37.34.66.73.86,1.17s.3.96.3,1.57c0,.74-.16,1.39-.49,1.93s-.76,1-1.31,1.36-1.18.63-1.89.81-1.46.26-2.24.26c-1.54,0-2.88-.3-4.01-.89Z"/>
|
||||
<path class="cls-16" d="M307.72,290.74c-.47-.26-1-.4-1.6-.4-1.68,0-2.52,1.06-2.52,3.18v2.31h3.52v2.05h-3.52v12.95h-2.39v-12.95h-2.56v-2.05h2.56v-2.43c0-1.57.45-2.81,1.36-3.73.91-.91,2.04-1.37,3.4-1.37.73,0,1.31.09,1.74.26v2.17Z"/>
|
||||
<path class="cls-16" d="M312.1,310.84h-2.4v-22.21h2.4v22.21Z"/>
|
||||
<path class="cls-16" d="M323.23,311.19c-2.22,0-3.99-.7-5.31-2.1s-1.98-3.26-1.98-5.57c0-2.52.69-4.49,2.07-5.9s3.24-2.12,5.58-2.12,3.98.69,5.24,2.07,1.88,3.29,1.88,5.73-.68,4.31-2.03,5.75-3.17,2.16-5.44,2.16ZM323.41,297.51c-1.54,0-2.76.53-3.66,1.57-.9,1.05-1.35,2.5-1.35,4.34s.45,3.18,1.36,4.2,2.12,1.54,3.65,1.54,2.75-.5,3.58-1.51,1.25-2.44,1.25-4.29-.42-3.32-1.25-4.34-2.03-1.52-3.58-1.52Z"/>
|
||||
<path class="cls-16" d="M353.44,295.84l-4.5,15h-2.49l-3.09-10.74c-.12-.41-.2-.87-.23-1.39h-.06c-.03.35-.13.81-.31,1.36l-3.35,10.77h-2.4l-4.54-15h2.52l3.11,11.28c.1.34.17.79.21,1.35h.12c.03-.43.12-.89.26-1.38l3.46-11.25h2.2l3.11,11.31c.1.36.17.81.22,1.35h.12c.02-.38.1-.83.25-1.35l3.05-11.31h2.37Z"/>
|
||||
<path class="cls-16" d="M234.65,346.15c-1.15.69-2.52,1.04-4.1,1.04-2.14,0-3.86-.7-5.18-2.09-1.31-1.39-1.97-3.2-1.97-5.41,0-2.47.71-4.46,2.12-5.96,1.42-1.5,3.31-2.25,5.67-2.25,1.32,0,2.48.24,3.49.73v2.46c-1.11-.78-2.3-1.17-3.57-1.17-1.53,0-2.79.55-3.77,1.65-.98,1.1-1.47,2.54-1.47,4.33s.46,3.14,1.38,4.16,2.16,1.52,3.71,1.52c1.31,0,2.54-.43,3.69-1.3v2.29Z"/>
|
||||
<path class="cls-16" d="M244.55,347.19c-2.22,0-3.99-.7-5.31-2.1s-1.98-3.26-1.98-5.57c0-2.52.69-4.49,2.07-5.9s3.24-2.12,5.58-2.12,3.98.69,5.24,2.07,1.88,3.29,1.88,5.73-.68,4.31-2.03,5.75-3.17,2.16-5.44,2.16ZM244.73,333.51c-1.54,0-2.76.53-3.66,1.57-.9,1.05-1.35,2.5-1.35,4.34s.45,3.18,1.36,4.2,2.12,1.54,3.65,1.54,2.75-.5,3.58-1.51,1.25-2.44,1.25-4.29-.42-3.32-1.25-4.34-2.03-1.52-3.58-1.52Z"/>
|
||||
<path class="cls-16" d="M268.31,346.84h-2.4v-8.55c0-3.18-1.16-4.78-3.49-4.78-1.2,0-2.19.45-2.98,1.36s-1.18,2.04-1.18,3.42v8.55h-2.4v-15h2.4v2.49h.06c1.13-1.89,2.77-2.84,4.92-2.84,1.64,0,2.9.53,3.76,1.59s1.3,2.59,1.3,4.59v9.17Z"/>
|
||||
<path class="cls-16" d="M279.8,346.69c-.57.31-1.31.47-2.24.47-2.63,0-3.94-1.46-3.94-4.39v-8.88h-2.58v-2.05h2.58v-3.66l2.4-.78v4.44h3.78v2.05h-3.78v8.45c0,1.01.17,1.72.51,2.15s.91.64,1.7.64c.61,0,1.13-.17,1.57-.5v2.05Z"/>
|
||||
<path class="cls-16" d="M290.83,334.27c-.42-.32-1.03-.48-1.82-.48-1.03,0-1.88.48-2.57,1.45s-1.03,2.29-1.03,3.96v7.65h-2.4v-15h2.4v3.09h.06c.34-1.05.86-1.88,1.57-2.47s1.49-.89,2.36-.89c.62,0,1.1.07,1.44.21v2.49Z"/>
|
||||
<path class="cls-16" d="M299.71,347.19c-2.22,0-3.99-.7-5.31-2.1s-1.98-3.26-1.98-5.57c0-2.52.69-4.49,2.07-5.9s3.24-2.12,5.58-2.12,3.98.69,5.24,2.07,1.88,3.29,1.88,5.73-.68,4.31-2.03,5.75-3.17,2.16-5.44,2.16ZM299.88,333.51c-1.54,0-2.76.53-3.66,1.57-.9,1.05-1.35,2.5-1.35,4.34s.45,3.18,1.36,4.2,2.12,1.54,3.65,1.54,2.75-.5,3.58-1.51,1.25-2.44,1.25-4.29-.42-3.32-1.25-4.34-2.03-1.52-3.58-1.52Z"/>
|
||||
<path class="cls-16" d="M313.42,346.84h-2.4v-22.21h2.4v22.21Z"/>
|
||||
<path class="cls-16" d="M320.68,346.84h-2.4v-22.21h2.4v22.21Z"/>
|
||||
<path class="cls-16" d="M337.6,339.94h-10.59c.04,1.67.49,2.96,1.35,3.87s2.04,1.36,3.54,1.36c1.69,0,3.24-.56,4.66-1.67v2.26c-1.32.96-3.06,1.44-5.23,1.44s-3.78-.68-5-2.04c-1.21-1.36-1.82-3.28-1.82-5.75,0-2.33.66-4.24,1.98-5.71s2.97-2.21,4.93-2.21,3.48.63,4.56,1.9,1.61,3.03,1.61,5.29v1.26ZM335.14,337.9c0-1.39-.34-2.47-1-3.24s-1.57-1.16-2.75-1.16-2.09.41-2.89,1.22-1.28,1.87-1.46,3.18h8.1Z"/>
|
||||
<path class="cls-16" d="M349.06,334.27c-.42-.32-1.03-.48-1.82-.48-1.03,0-1.88.48-2.57,1.45s-1.03,2.29-1.03,3.96v7.65h-2.4v-15h2.4v3.09h.06c.34-1.05.86-1.88,1.57-2.47s1.49-.89,2.36-.89c.62,0,1.1.07,1.44.21v2.49Z"/>
|
||||
</g>
|
||||
<text class="cls-17" transform="translate(492.91 429.7)"><tspan class="cls-15" x="0" y="0">S</tspan><tspan x="14.97" y="0">tirred reactor</tspan></text>
|
||||
<text class="cls-17" transform="translate(781.34 404.18)"><tspan x="0" y="0">Pressure valve</tspan></text>
|
||||
<text class="cls-17" transform="translate(1094.65 533.76)"><tspan x="0" y="0">Capture tank</tspan></text>
|
||||
<polyline class="cls-5" points="919.56 339.95 1005.55 339.95 1005.55 165.22 1127.62 165.22"/>
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 10 KiB |
124
doc/sphinx/_static/images/samples/stirred-reactor-solo.svg
Normal file
124
doc/sphinx/_static/images/samples/stirred-reactor-solo.svg
Normal file
@@ -0,0 +1,124 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<svg id="Layer_1" data-name="Layer 1" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 571.47 323.48">
|
||||
<defs>
|
||||
<style>
|
||||
.cls-1 {
|
||||
stroke: #363;
|
||||
}
|
||||
|
||||
.cls-1, .cls-2, .cls-3, .cls-4, .cls-5, .cls-6 {
|
||||
stroke-miterlimit: 10;
|
||||
}
|
||||
|
||||
.cls-1, .cls-7 {
|
||||
fill: #fff1cc;
|
||||
}
|
||||
|
||||
.cls-1, .cls-6 {
|
||||
stroke-width: 3px;
|
||||
}
|
||||
|
||||
.cls-8, .cls-9, .cls-10, .cls-11 {
|
||||
fill: #000;
|
||||
}
|
||||
|
||||
.cls-8, .cls-7 {
|
||||
stroke-width: 0px;
|
||||
}
|
||||
|
||||
.cls-2 {
|
||||
stroke-dasharray: 0 0 2.01 3.01;
|
||||
}
|
||||
|
||||
.cls-2, .cls-3, .cls-4, .cls-5, .cls-6 {
|
||||
fill: none;
|
||||
}
|
||||
|
||||
.cls-2, .cls-3, .cls-5 {
|
||||
stroke: #8c681a;
|
||||
stroke-width: 1.5px;
|
||||
}
|
||||
|
||||
.cls-12 {
|
||||
letter-spacing: -.13em;
|
||||
}
|
||||
|
||||
.cls-3 {
|
||||
stroke-dasharray: 0 0 2 3;
|
||||
}
|
||||
|
||||
.cls-13, .cls-9 {
|
||||
font-family: Cambria-Italic, Cambria;
|
||||
font-style: italic;
|
||||
}
|
||||
|
||||
.cls-9, .cls-10, .cls-11 {
|
||||
font-size: 23px;
|
||||
}
|
||||
|
||||
.cls-14 {
|
||||
letter-spacing: -.1em;
|
||||
}
|
||||
|
||||
.cls-15 {
|
||||
letter-spacing: -.11em;
|
||||
}
|
||||
|
||||
.cls-4 {
|
||||
stroke: #39c;
|
||||
stroke-width: 2px;
|
||||
}
|
||||
|
||||
.cls-10 {
|
||||
font-family: SegoeUI, 'Segoe UI';
|
||||
}
|
||||
|
||||
.cls-16 {
|
||||
font-family: Cambria, Cambria;
|
||||
}
|
||||
|
||||
.cls-6 {
|
||||
stroke: #000;
|
||||
}
|
||||
</style>
|
||||
</defs>
|
||||
<polyline class="cls-4" points="89.81 123 173.72 123 173.72 75.69 401.63 75.69 401.63 227.29 485.2 227.29"/>
|
||||
<polyline class="cls-4" points="89.81 152.8 173.41 152.8 173.41 299.22 402.01 299.22 402.01 256.74 485.2 256.74"/>
|
||||
<g>
|
||||
<rect class="cls-7" x="182.18" y="84.43" width="210.65" height="205.12"/>
|
||||
<g>
|
||||
<polyline class="cls-5" points="182.18 85.43 182.18 84.43 183.18 84.43"/>
|
||||
<line class="cls-2" x1="186.19" y1="84.43" x2="390.32" y2="84.43"/>
|
||||
<polyline class="cls-5" points="391.83 84.43 392.83 84.43 392.83 85.43"/>
|
||||
<line class="cls-3" x1="392.83" y1="88.43" x2="392.83" y2="287.05"/>
|
||||
<polyline class="cls-5" points="392.83 288.55 392.83 289.55 391.83 289.55"/>
|
||||
<line class="cls-2" x1="388.82" y1="289.55" x2="184.68" y2="289.55"/>
|
||||
<polyline class="cls-5" points="183.18 289.55 182.18 289.55 182.18 288.55"/>
|
||||
<line class="cls-3" x1="182.18" y1="285.55" x2="182.18" y2="86.93"/>
|
||||
</g>
|
||||
</g>
|
||||
<text class="cls-11" transform="translate(6.73 163.64)"><tspan class="cls-13" x="0" y="0">ṁ</tspan><tspan class="cls-16" x="18.37" y="0">(</tspan><tspan class="cls-13" x="27.16" y="0">t</tspan><tspan class="cls-16" x="35.1" y="0">)</tspan></text>
|
||||
<text class="cls-11" transform="translate(504.86 266.81)"><tspan class="cls-13" x="0" y="0">ṁ</tspan><tspan class="cls-16" x="18.37" y="0">(</tspan><tspan class="cls-13" x="27.16" y="0">t</tspan><tspan class="cls-16" x="35.1" y="0">)</tspan></text>
|
||||
<text class="cls-10" transform="translate(104.63 115.8)"><tspan x="0" y="0">Inlet</tspan></text>
|
||||
<text class="cls-10" transform="translate(428.11 213.22)"><tspan x="0" y="0">Outlet</tspan></text>
|
||||
<g>
|
||||
<polyline class="cls-1" points="245.01 1.5 286.33 1.5 327.37 1.5"/>
|
||||
<line class="cls-1" x1="287.5" y1="201.85" x2="287.5" y2="1.5"/>
|
||||
</g>
|
||||
<ellipse class="cls-1" cx="243.98" cy="201.85" rx="43.52" ry="11.14"/>
|
||||
<ellipse class="cls-1" cx="331.03" cy="201.6" rx="43.52" ry="11.14"/>
|
||||
<g>
|
||||
<path class="cls-6" d="M325.55,106.13c-18.57,0-33.85,1.27-45.06,2.59-4.08.48-14.17,1.73-26.16,6.47-15.99,6.33-18.45,12.17-19.17,14.5-.19.62-1.53,5.26.52,10.1,2.43,5.74,8.19,8.37,14.24,10.62,17.59,6.54,32.63,8.03,32.63,8.03,6.56.65,14.5,1.24,23.61,1.51"/>
|
||||
<polygon class="cls-8" points="301.97 165.95 324.78 160 302.05 153.75 301.97 165.95"/>
|
||||
</g>
|
||||
<path class="cls-1" d="M287.5,91.37v38.07"/>
|
||||
<text class="cls-9" transform="translate(200.46 276.5)"><tspan class="cls-12" x="0" y="0">P</tspan><tspan x="9.85" y="0">, </tspan><tspan class="cls-14" x="19.5" y="0">V</tspan><tspan x="30.37" y="0">, </tspan><tspan class="cls-15" x="40.01" y="0">T</tspan><tspan x="50.63" y="0">, Yᵢ</tspan></text>
|
||||
<g>
|
||||
<line class="cls-6" y1="136.44" x2="61.33" y2="136.44"/>
|
||||
<polygon class="cls-8" points="58.27 146.91 76.4 136.44 58.27 125.96 58.27 146.91"/>
|
||||
</g>
|
||||
<g>
|
||||
<line class="cls-6" x1="495.06" y1="239.64" x2="556.4" y2="239.64"/>
|
||||
<polygon class="cls-8" points="553.33 250.12 571.47 239.64 553.33 229.17 553.33 250.12"/>
|
||||
</g>
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 4.4 KiB |
295
samples/python/reactors/continuous_reactor.py
Normal file
295
samples/python/reactors/continuous_reactor.py
Normal file
@@ -0,0 +1,295 @@
|
||||
r"""
|
||||
Continuously Stirred Tank Reactor
|
||||
=================================
|
||||
|
||||
In this example we will illustrate how Cantera can be used to simulate a
|
||||
`continuously stirred tank reactor <https://en.wikipedia.org/wiki/Continuous_stirred-tank_reactor>`__
|
||||
(CSTR), also interchangeably referred to as a perfectly stirred reactor (PSR), a well
|
||||
stirred reactor (WSR), a jet stirred reactor (JSR), or a
|
||||
`Longwell reactor <https://nap.nationalacademies.org/read/13160/chapter/48>`__ (and
|
||||
there may well be more "aliases").
|
||||
|
||||
Requires: cantera >= 3.0, matplotlib >= 2.0, pandas
|
||||
|
||||
.. tags:: Python, combustion, reactor network, well-stirred reactor
|
||||
|
||||
Simulation of a CSTR/PSR/WSR
|
||||
----------------------------
|
||||
|
||||
A diagram of a CSTR is shown below:
|
||||
|
||||
.. image:: /_static/images/samples/stirred-reactor-solo.svg
|
||||
:width: 50%
|
||||
:alt: A continuously stirred tank reactor with inflow and outflow
|
||||
:align: center
|
||||
|
||||
As the figure illustrates, this is an open system (unlike a batch reactor, which is
|
||||
isolated). *P*, *V* and *T* are the reactor's pressure, volume and temperature
|
||||
respectively. The mass flow rate at which reactants come in is the same as that of the
|
||||
products which exit, and on average this mass stays in the reactor for a characteristic
|
||||
time :math:`\tau`, called the *residence time*. This is a key quantity in sizing the
|
||||
reactor and is defined as follows:
|
||||
|
||||
.. math::
|
||||
|
||||
\tau = \frac{m}{\dot{m}}
|
||||
|
||||
where :math:`m` is the mass of the gas.
|
||||
"""
|
||||
|
||||
# %%
|
||||
# Import modules and set plotting defaults
|
||||
# ----------------------------------------
|
||||
|
||||
import time
|
||||
from io import StringIO
|
||||
import matplotlib.pyplot as plt
|
||||
import pandas as pd
|
||||
import cantera as ct
|
||||
|
||||
print(f"Running Cantera version: {ct.__version__}")
|
||||
|
||||
|
||||
# %%
|
||||
# Define the gas
|
||||
# --------------
|
||||
#
|
||||
# In this example, we will work with n-C₇H₁₆/O₂/He mixtures, for which experimental data
|
||||
# can be found in the paper by Zhang et al. [1]_ We will use the same mechanism reported
|
||||
# in the paper. It consists of 1268 species and 5336 reactions.
|
||||
|
||||
gas = ct.Solution("example_data/n-hexane-NUIG-2015.yaml")
|
||||
|
||||
# %%
|
||||
# Define initial conditions
|
||||
# -------------------------
|
||||
#
|
||||
# Inlet conditions for the gas and reactor parameters
|
||||
# ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
reactor_temperature = 925 # Kelvin
|
||||
reactor_pressure = 1.046138 * ct.one_atm # in atm. This equals 1.06 bars
|
||||
inlet_concentrations = {"NC7H16": 0.005, "O2": 0.0275, "HE": 0.9675}
|
||||
gas.TPX = reactor_temperature, reactor_pressure, inlet_concentrations
|
||||
|
||||
residence_time = 2 # s
|
||||
reactor_volume = 30.5 * (1e-2) ** 3 # m3
|
||||
|
||||
# %%
|
||||
# Simulation parameters
|
||||
# ^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
# Simulation termination criterion
|
||||
max_simulation_time = 50 # seconds
|
||||
|
||||
# %%
|
||||
# Reactor arrangement
|
||||
# -------------------
|
||||
#
|
||||
# We showed a cartoon of the reactor in the first figure in this notebook, but to
|
||||
# actually simulate that, we need a few peripherals. A mass-flow controller upstream of
|
||||
# the stirred reactor will allow us to flow gases in, and in-turn, a "reservoir" which
|
||||
# simulates a gas tank is required to supply gases to the mass flow controller.
|
||||
# Downstream of the reactor, we install a pressure regulator which allows the reactor
|
||||
# pressure to stay within. Downstream of the regulator we will need another reservoir
|
||||
# which acts like a "sink" or capture tank to capture all exhaust gases (even our
|
||||
# simulations are environmentally friendly!). This arrangement is illustrated below:
|
||||
#
|
||||
# .. image:: /_static/images/samples/stirred-reactor-network.svg
|
||||
# :width: 80%
|
||||
# :alt: A complete reactor network representing a continuously stirred tank reactor
|
||||
# :align: center
|
||||
#
|
||||
# Initialize the stirred reactor and connect all peripherals
|
||||
# ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
fuel_air_mixture_tank = ct.Reservoir(gas)
|
||||
exhaust = ct.Reservoir(gas)
|
||||
|
||||
stirred_reactor = ct.IdealGasMoleReactor(gas, energy="off", volume=reactor_volume)
|
||||
|
||||
mass_flow_controller = ct.MassFlowController(
|
||||
upstream=fuel_air_mixture_tank,
|
||||
downstream=stirred_reactor,
|
||||
mdot=stirred_reactor.mass / residence_time,
|
||||
)
|
||||
|
||||
pressure_regulator = ct.PressureController(
|
||||
upstream=stirred_reactor,
|
||||
downstream=exhaust,
|
||||
primary=mass_flow_controller,
|
||||
K=1e-3,
|
||||
)
|
||||
|
||||
reactor_network = ct.ReactorNet([stirred_reactor])
|
||||
|
||||
# Create a SolutionArray to store the data
|
||||
time_history = ct.SolutionArray(gas, extra=["t"])
|
||||
|
||||
# Set the maximum simulation time
|
||||
max_simulation_time = 50 # seconds
|
||||
|
||||
# Start the stopwatch
|
||||
tic = time.time()
|
||||
|
||||
# Set simulation start time to zero
|
||||
t = 0
|
||||
counter = 1
|
||||
while t < max_simulation_time:
|
||||
t = reactor_network.step()
|
||||
|
||||
# We will store only every 10th value. Remember, we have 1200+ species, so there
|
||||
# will be 1200+ columns for us to work with
|
||||
if counter % 10 == 0:
|
||||
# Extract the state of the reactor
|
||||
time_history.append(stirred_reactor.thermo.state, t=t)
|
||||
|
||||
counter += 1
|
||||
|
||||
# Stop the stopwatch
|
||||
toc = time.time()
|
||||
|
||||
print(f"Simulation Took {toc-tic:3.2f}s to compute, with {counter} steps")
|
||||
|
||||
# %%
|
||||
# Plot the results
|
||||
# ^^^^^^^^^^^^^^^^
|
||||
#
|
||||
# As a test, we plot the mole fraction of CO and see if the simulation has converged. If
|
||||
# not, go back and adjust max. number of steps and/or simulation time.
|
||||
|
||||
plt.figure()
|
||||
plt.semilogx(time_history.t, time_history("CO").X, "-o")
|
||||
plt.xlabel("Time (s)")
|
||||
plt.ylabel("Mole Fraction : $X_{CO}$")
|
||||
|
||||
# %%
|
||||
# Illustration : Modeling experimental data
|
||||
# -----------------------------------------
|
||||
#
|
||||
# Let us see if the reactor can reproduce actual experimental measurements.
|
||||
#
|
||||
# We first load the data. This is also supplied in the paper by Zhang et al. [1]_ as an
|
||||
# excel sheet
|
||||
|
||||
experimental_data_csv = """
|
||||
T,NC7H16,O2,CO,CO2
|
||||
500,5.07E-03,2.93E-02,0.00E+00,0.00E+00
|
||||
525,4.92E-03,2.86E-02,0.00E+00,0.00E+00
|
||||
550,4.66E-03,2.85E-02,0.00E+00,0.00E+00
|
||||
575,4.16E-03,2.63E-02,2.43E-04,1.01E-04
|
||||
600,3.55E-03,2.33E-02,9.68E-04,2.51E-04
|
||||
625,3.36E-03,2.31E-02,1.42E-03,2.67E-04
|
||||
650,3.67E-03,2.45E-02,9.16E-04,1.46E-04
|
||||
675,4.38E-03,2.77E-02,2.25E-04,0.00E+00
|
||||
700,4.79E-03,2.87E-02,0.00E+00,0.00E+00
|
||||
725,4.89E-03,2.93E-02,0.00E+00,0.00E+00
|
||||
750,4.91E-03,2.84E-02,0.00E+00,0.00E+00
|
||||
775,4.93E-03,2.80E-02,0.00E+00,0.00E+00
|
||||
800,4.78E-03,2.82E-02,0.00E+00,0.00E+00
|
||||
825,4.41E-03,2.80E-02,1.49E-05,0.00E+00
|
||||
850,3.68E-03,2.80E-02,4.18E-04,1.66E-04
|
||||
875,2.13E-03,2.45E-02,1.65E-03,2.22E-04
|
||||
900,1.03E-03,2.05E-02,5.51E-03,3.69E-04
|
||||
925,5.82E-04,1.79E-02,8.59E-03,6.78E-04
|
||||
950,3.88E-04,1.47E-02,1.05E-02,1.07E-03
|
||||
975,2.35E-04,1.28E-02,1.19E-02,1.36E-03
|
||||
1000,1.14E-04,1.16E-02,1.34E-02,1.82E-03
|
||||
1025,4.83E-05,9.88E-03,1.52E-02,2.41E-03
|
||||
1050,1.64E-05,8.16E-03,1.83E-02,2.97E-03
|
||||
1075,1.22E-06,5.48E-03,1.95E-02,3.67E-03
|
||||
1100,0.00E+00,3.24E-03,2.14E-02,4.38E-03
|
||||
"""
|
||||
|
||||
experimental_data = pd.read_csv(StringIO(experimental_data_csv))
|
||||
experimental_data.head()
|
||||
|
||||
# %%
|
||||
|
||||
# Define all the temperatures at which we will run simulations. These should overlap
|
||||
# with the values reported in the paper as much as possible
|
||||
T = [650, 700, 750, 775, 825, 850, 875, 925, 950, 1075, 1100]
|
||||
|
||||
# Create a SolutionArray to store values for the above points
|
||||
temp_dependence = ct.SolutionArray(gas)
|
||||
|
||||
# %%
|
||||
# Now we simply run the reactor code we used above for each temperature
|
||||
|
||||
concentrations = inlet_concentrations
|
||||
|
||||
for reactor_temperature in T:
|
||||
# Use concentrations from the previous iteration to speed up convergence
|
||||
gas.TPX = reactor_temperature, reactor_pressure, concentrations
|
||||
|
||||
stirred_reactor = ct.IdealGasReactor(gas, energy="off", volume=reactor_volume)
|
||||
fuel_air_mixture_tank = ct.Reservoir(gas)
|
||||
mass_flow_controller = ct.MassFlowController(
|
||||
upstream=fuel_air_mixture_tank,
|
||||
downstream=stirred_reactor,
|
||||
mdot=stirred_reactor.mass / residence_time,
|
||||
)
|
||||
pressure_regulator = ct.PressureController(
|
||||
upstream=stirred_reactor, downstream=exhaust, primary=mass_flow_controller
|
||||
)
|
||||
reactor_network = ct.ReactorNet([stirred_reactor])
|
||||
|
||||
# Re-run the isothermal simulations
|
||||
tic = time.time()
|
||||
reactor_network.advance(max_simulation_time)
|
||||
toc = time.time()
|
||||
print(f"Simulation at T={reactor_temperature}K took {toc-tic:3.2f}s to compute")
|
||||
|
||||
concentrations = stirred_reactor.thermo.X
|
||||
temp_dependence.append(stirred_reactor.thermo.state)
|
||||
|
||||
# %%
|
||||
# Compare the model results with experimental data
|
||||
# ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
plt.figure()
|
||||
plt.plot(
|
||||
temp_dependence.T, temp_dependence("NC7H16").X, color="C0", label="$nC_{7}H_{16}$"
|
||||
)
|
||||
plt.plot(temp_dependence.T, temp_dependence("CO").X, color="C1", label="CO")
|
||||
plt.plot(temp_dependence.T, temp_dependence("O2").X, color="C2", label="O$_{2}$")
|
||||
|
||||
plt.plot(
|
||||
experimental_data["T"],
|
||||
experimental_data["NC7H16"],
|
||||
color="C0",
|
||||
marker="o",
|
||||
label="$nC_{7}H_{16}$ (exp)",
|
||||
)
|
||||
plt.plot(
|
||||
experimental_data["T"],
|
||||
experimental_data["CO"],
|
||||
color="C1",
|
||||
marker="^",
|
||||
linestyle="none",
|
||||
label="CO (exp)",
|
||||
)
|
||||
plt.plot(
|
||||
experimental_data["T"],
|
||||
experimental_data["O2"],
|
||||
color="C2",
|
||||
marker="s",
|
||||
linestyle="none",
|
||||
label="O$_2$ (exp)",
|
||||
)
|
||||
|
||||
plt.xlabel("Temperature (K)")
|
||||
plt.ylabel(r"Mole Fractions")
|
||||
|
||||
plt.xlim([650, 1100])
|
||||
plt.legend(loc=1)
|
||||
|
||||
# %%
|
||||
# References
|
||||
# ----------
|
||||
#
|
||||
# .. [1] K. Zhang, C. Banyon, C. Togbé, P. Dagaut, J. Bugler, H. J. Curran (2015). "An
|
||||
# experimental and kinetic modeling study of n-hexane oxidation," *Combustion and
|
||||
# Flame* 162:11, 4194-4207, https://doi.org/10.1016/j.combustflame.2015.08.001.
|
||||
|
||||
# sphinx_gallery_thumbnail_number = -1
|
||||
Reference in New Issue
Block a user