/
Conditions.mo
7001 lines (6123 loc) · 292 KB
/
Conditions.mo
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
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
within FCSys;
package Conditions "Models to specify and measure operating conditions"
extends Modelica.Icons.SourcesPackage;
package Examples "Examples"
extends Modelica.Icons.ExamplesPackage;
model BoundaryCondition
"Test the conditions for the boundary of a subregion"
extends Modelica.Icons.Example;
ByConnector.BoundaryBus.Single.Sink boundary
annotation (Placement(transformation(extent={{-10,14},{10,34}})));
Subregions.Subregion subregion(
L={1,1,1}*U.cm,
inclTransX=false,
inclTransY=true,
inclTransZ=false,
graphite('inclC+'=true, 'C+'(epsilon=0.5)),
gas(inclH2O=true))
annotation (Placement(transformation(extent={{-10,-10},{10,10}})));
inner Conditions.Environment environment
annotation (Placement(transformation(extent={{30,30},{50,50}})));
equation
connect(subregion.yPositive, boundary.boundary) annotation (Line(
points={{6.10623e-16,10},{-3.36456e-22,16},{6.10623e-16,16},{
6.10623e-16,20}},
color={127,127,127},
thickness=0.5,
smooth=Smooth.None));
annotation (experiment, Commands(file=
"Resources/Scripts/Dymola/Conditions.Examples.BoundaryCondition.mos"
"Conditions.Examples.BoundaryCondition.mos"));
end BoundaryCondition;
model Router
"<html>Test the <a href=\"modelica://FCSys.Conditions.Router\">Router</a> model</html>"
extends Modelica.Icons.Example;
Conditions.Router router
annotation (Placement(transformation(extent={{-10,-10},{10,10}})));
ByConnector.BoundaryBus.Single.Source fastFlow(gas(inclH2=true,H2(
materialSet(y=-U.A)))) annotation (Placement(transformation(
extent={{-10,-10},{10,10}},
rotation=90,
origin={-30,20})));
ByConnector.BoundaryBus.Single.Source slowFlow(gas(inclH2=true,H2(
materialSet(y=-U.mA)))) annotation (Placement(transformation(
extent={{-10,-10},{10,10}},
rotation=90,
origin={-30,-20})));
ByConnector.BoundaryBus.Single.Sink sink2(gas(inclH2=true)) annotation (
Placement(transformation(
extent={{-10,-10},{10,10}},
rotation=270,
origin={30,-20})));
ByConnector.BoundaryBus.Single.Sink sink1(gas(inclH2=true)) annotation (
Placement(transformation(
extent={{-10,-10},{10,10}},
rotation=270,
origin={30,20})));
equation
connect(router.positive2, sink1.boundary) annotation (Line(
points={{8,4},{20,4},{20,20},{26,20},{26,20}},
color={127,127,127},
thickness=0.5,
smooth=Smooth.None));
connect(router.positive1, sink2.boundary) annotation (Line(
points={{8,-4},{20,-4},{20,-20},{26,-20}},
color={127,127,127},
thickness=0.5,
smooth=Smooth.None));
connect(fastFlow.boundary, router.negative2) annotation (Line(
points={{-26,20},{-20,20},{-20,4},{-8,4}},
color={127,127,127},
thickness=0.5,
smooth=Smooth.None));
connect(slowFlow.boundary, router.negative1) annotation (Line(
points={{-26,-20},{-20,-20},{-20,-4},{-8,-4}},
color={127,127,127},
thickness=0.5,
smooth=Smooth.None));
annotation (Diagram(coordinateSystem(preserveAspectRatio=false, extent={{
-100,-100},{100,100}}), graphics), Commands(file=
"Resources/Scripts/Dymola/Conditions.Examples.Router.mos"
"Conditions.Examples.Router.mos"));
end Router;
model AnodeAdapter
"<html>Test the <a href=\"modelica://FCSys.Conditions.Adapters.Anode\">Anode</a> adapter</html>"
extends Modelica.Icons.Example;
inner Modelica.Fluid.System system(T_ambient=293.15 + 5)
annotation (Placement(transformation(extent={{40,70},{60,90}})));
inner Conditions.Environment environment(T=350*U.K)
annotation (Placement(transformation(extent={{70,72},{90,92}})));
FCSys.Subregions.SubregionNoIonomer subregion(
L={1,1,1}*U.cm,
inclTransY=false,
inclTransZ=false,
gas(
inclH2=true,
inclH2O=true,
H2O(initEnergy=Init.none)),
graphite('inclC+'=true, 'incle-'=true),
liquid(inclH2O=true))
annotation (Placement(transformation(extent={{-50,-10},{-30,10}})));
Adapters.MSL.Anode anodeAdapter(redeclare package LiquidMedium =
Modelica.Media.CompressibleLiquids.LinearColdWater)
annotation (Placement(transformation(extent={{-20,-10},{0,10}})));
Modelica.Electrical.Analog.Basic.Ground ground
annotation (Placement(transformation(extent={{0,-40},{20,-20}})));
Modelica.Fluid.Vessels.ClosedVolume gasVolume(
use_portsData=false,
nPorts=1,
V=1e-6,
use_HeatTransfer=true,
redeclare
Modelica.Fluid.Vessels.BaseClasses.HeatTransfer.IdealHeatTransfer
HeatTransfer,
redeclare package Medium = Adapters.MSL.Media.AnodeGas,
medium(p(fixed=true),X(each fixed=true)))
annotation (Placement(transformation(extent={{30,20},{50,40}})));
Modelica.Fluid.Vessels.ClosedVolume liquidVolume(
nPorts=1,
use_HeatTransfer=true,
redeclare
Modelica.Fluid.Vessels.BaseClasses.HeatTransfer.IdealHeatTransfer
HeatTransfer,
V=0.5e-6,
use_portsData=false,
redeclare package Medium =
Modelica.Media.CompressibleLiquids.LinearColdWater,
medium(p(fixed=true),T(fixed=true)))
annotation (Placement(transformation(extent={{70,20},{90,40}})));
equation
connect(ground.p, anodeAdapter.pin) annotation (Line(
points={{10,-20},{10,2},{-6,2}},
color={0,0,255},
smooth=Smooth.None));
connect(subregion.xPositive, anodeAdapter.boundary) annotation (Line(
points={{-30,6.10623e-016},{-24,6.10623e-016},{-24,6.10623e-016},{-14,
6.10623e-016}},
color={127,127,127},
thickness=0.5,
smooth=Smooth.None));
connect(gasVolume.heatPort, anodeAdapter.heatPort) annotation (Line(
points={{30,30},{20,30},{20,-2},{-6,-2}},
color={191,0,0},
smooth=Smooth.None));
connect(gasVolume.ports[1], anodeAdapter.gasPort) annotation (Line(
points={{40,20},{40,6},{-6,6}},
color={0,127,255},
smooth=Smooth.None));
connect(liquidVolume.heatPort, anodeAdapter.heatPort) annotation (Line(
points={{70,30},{60,30},{60,-2},{-6,-2}},
color={191,0,0},
smooth=Smooth.None));
connect(anodeAdapter.liquidPort, liquidVolume.ports[1]) annotation (Line(
points={{-6,-6},{80,-6},{80,20}},
color={0,127,255},
smooth=Smooth.None));
annotation (experiment, Commands(file=
"Resources/Scripts/Dymola/Conditions.Examples.Adapteminus.mos"
"Conditions.Examples.Adapteminus.mos"));
end AnodeAdapter;
model Stoichiometry "Test the stoichiometry of a reaction"
extends Modelica.Icons.Example;
import Modelica.Math.BooleanVectors.countTrue;
// Assumptions
// -----------
// Included components of translational momentum
constant Boolean inclTransX=true "X" annotation (choices(
__Dymola_checkBox=true), Dialog(
tab="Assumptions",
group="Included transport axes",
compact=true));
constant Boolean inclTransY=false "Y" annotation (choices(
__Dymola_checkBox=true), Dialog(
tab="Assumptions",
group="Included transport axes",
compact=true));
constant Boolean inclTransZ=false "Z" annotation (choices(
__Dymola_checkBox=true), Dialog(
tab="Assumptions",
group="Included transport axes",
compact=true));
inner Conditions.Environment environment(T=360*U.K)
annotation (Placement(transformation(extent={{40,40},{60,60}})));
replaceable ByConnector.Chemical.Current speciesA(
final inclTransX=inclTransX,
final inclTransY=inclTransY,
final inclTransZ=inclTransZ,
sT=2000*U.K,
redeclare Modelica.Blocks.Sources.Ramp set(duration=100, height=-1*U.A))
annotation (Placement(transformation(extent={{-50,0},{-30,20}})));
replaceable ByConnector.Chemical.Potential speciesB(
final inclTransX=inclTransX,
final inclTransY=inclTransY,
final inclTransZ=inclTransZ,
sT=3000*U.K)
annotation (Placement(transformation(extent={{30,0},{50,20}})));
replaceable ByConnector.Chemical.Potential speciesC(
final inclTransX=inclTransX,
final inclTransY=inclTransY,
final inclTransZ=inclTransZ,
sT=4000*U.K)
annotation (Placement(transformation(extent={{30,-20},{50,0}})));
Conditions.Adapters.ChemicalReaction A(
m=U.g/U.mol,
final n_trans=n_trans,
n=-1)
annotation (Placement(transformation(extent={{-30,-10},{-10,10}})));
Conditions.Adapters.ChemicalReaction B(
m=U.g/U.mol,
final n_trans=n_trans,
n=2) annotation (Placement(transformation(extent={{30,-10},{10,10}})));
Conditions.Adapters.ChemicalReaction C(
m=U.g/U.mol,
final n_trans=n_trans,
n=2) annotation (Placement(transformation(extent={{30,-30},{10,-10}})));
protected
final inner constant Boolean inclTrans[Axis]={inclTransX,inclTransY,
inclTransZ}
"true, if each component of translational momentum is included";
final inner constant Integer n_trans=countTrue(inclTrans)
"Number of components of translational momentum";
equation
connect(A.chemical, speciesA.chemical) annotation (Line(
points={{-24,0},{-40,0},{-40,6}},
color={239,142,1},
smooth=Smooth.None));
connect(B.chemical, speciesB.chemical) annotation (Line(
points={{24,0},{40,0},{40,6}},
color={239,142,1},
smooth=Smooth.None));
connect(C.chemical, speciesC.chemical) annotation (Line(
points={{24,-20},{40,-20},{40,-14}},
color={239,142,1},
smooth=Smooth.None));
connect(C.reaction, B.reaction) annotation (Line(
points={{16,-20},{0,-20},{0,0},{16,0}},
color={239,142,1},
smooth=Smooth.None));
connect(B.reaction, A.reaction) annotation (Line(
points={{16,0},{-16,0}},
color={239,142,1},
smooth=Smooth.None));
annotation (
experiment(StopTime=120),
Diagram(coordinateSystem(preserveAspectRatio=false, extent={{-100,-100},
{100,100}}), graphics),
Commands(file=
"Resources/Scripts/Dymola/Conditions.Examples.Stoichiometry.mos"
"Conditions.Examples.Stoichiometry.mos"));
end Stoichiometry;
end Examples;
package Adapters
"<html>Interfaces to the <a href=\"modelica://Modelica\">Modelica Standard Library</a></html>"
extends Modelica.Icons.Package;
model AmagatDalton
"<html>Adapter between the <a href=\"modelica://FCSys.Connectors.Amagat\">Amagat</a> and <a href=\"modelica://FCSys.Connectors.Dalton\">Dalton</a> connectors</html>"
extends FCSys.Icons.Names.Top1;
Connectors.Amagat amagat "Connector for additivity of volume" annotation
(Placement(transformation(extent={{-30,-10},{-10,10}}),
iconTransformation(extent={{-50,-10},{-30,10}})));
Connectors.Dalton dalton "Connector for additivity of pressure"
annotation (Placement(transformation(extent={{10,-10},{30,10}}),
iconTransformation(extent={{30,-10},{50,10}})));
equation
// Static balances
0 = amagat.p + dalton.p "Pressure";
0 = amagat.V + dalton.V "Volume";
annotation (
Documentation(info="<html><p>This model is used to convert the representation of mixtures
between Amagat's law of partial volumes and Dalton's law of partial pressures.</p>
<p>For more information, please see the documentation in the
<a href=\"modelica://FCSys.Connectors\">Connectors</a> package.</p></html>"),
Diagram(coordinateSystem(preserveAspectRatio=true, extent={{-100,-100},
{100,100}}), graphics),
Icon(coordinateSystem(preserveAspectRatio=false,extent={{-100,-100},{
100,100}}), graphics={Line(
points={{-30,0},{30,0}},
color={47,107,251},
smooth=Smooth.None),Polygon(
points={{0,20},{-20,0},{0,-20},{20,0},{0,20}},
lineColor={47,107,251},
smooth=Smooth.None,
fillColor={255,255,255},
fillPattern=FillPattern.Solid)}));
end AmagatDalton;
model ChemicalReaction
"<html>Adapter between the <a href=\"modelica://FCSys.Connectors.Chemical\">Chemical</a> and <a href=\"modelica://FCSys.Connectors.Reaction\">Reaction</a> connectors</html>"
// extends FCSys.Icons.Names.Top1;
constant Integer n_trans(min=1,max=3)
"Number of components of translational momentum" annotation (Dialog(
__Dymola_label="<html><i>n</i><sub>trans</sub></html>"));
// Note: This must be a constant rather than a parameter due to errors
// in Dymola 2014.
parameter Integer n "Stoichiometric coefficient"
annotation (Dialog(__Dymola_label="<html><i>n</i></html>"));
parameter Q.MassSpecific m "Specific mass" annotation (Dialog(group=
"Material properties", __Dymola_label="<html><i>m</i></html>"));
// Auxiliary variables (for analysis)
output Q.Velocity phi[n_trans](each stateSelect=StateSelect.never) =
actualStream(chemical.phi) if environment.analysis
"Velocity of the stream";
output Q.PotentialAbsolute sT(stateSelect=StateSelect.never) =
actualStream(chemical.sT) if environment.analysis
"Specific entropy-temperature product of the stream";
Connectors.Chemical chemical(redeclare final constant Integer n_trans=
n_trans) "Connector for a species in a chemical reaction"
annotation (Placement(transformation(extent={{-30,-10},{-10,10}}),
iconTransformation(extent={{-50,-10},{-30,10}})));
// Note: This redeclaration is necessary due to errors in Dymola 2014.
Connectors.Reaction reaction(final n_trans=n_trans)
"Connector for a chemical reaction" annotation (Placement(
transformation(extent={{10,-10},{30,10}}), iconTransformation(
extent={{30,-10},{50,10}})));
protected
outer Conditions.Environment environment "Environmental conditions";
equation
// Equal intensive properties
reaction.g = n*chemical.g "Chemical potential";
reaction.phi = chemical.phi "Velocity (upon outflow)";
reaction.sT = chemical.sT
"Specific entropy-temperature product (upon outflow)";
// Conservation (without storage)
0 = chemical.Ndot + n*reaction.Ndot "Material";
zeros(n_trans) = m*actualStream(chemical.phi)*chemical.Ndot + reaction.mPhidot
"Translational momentum";
0 = actualStream(chemical.sT)*chemical.Ndot + reaction.Qdot "Energy";
annotation (
Documentation(info="<html><p>This model is used to add the stoichiometrically-weighted chemical potential
of a species to the net chemical potential of a reaction. The species is produced at the
stoichiometrically-weighted rate of the reaction.</p>
<p>For more information, please see the documentation in the
<a href=\"modelica://FCSys.Connectors\">Connectors</a> package.</p></html>"),
Icon(coordinateSystem(preserveAspectRatio=false, extent={{-100,-100},{
100,100}}), graphics={Line(
points={{-30,0},{30,0}},
color={255,195,38},
smooth=Smooth.None),Text(
extent={{-100,20},{100,60}},
lineColor={0,0,0},
textString="%n %name"),Polygon(
points={{0,20},{-20,0},{0,-20},{20,0},{0,20}},
lineColor={255,195,38},
smooth=Smooth.None,
fillColor={255,255,255},
fillPattern=FillPattern.Solid)}),
Diagram(coordinateSystem(preserveAspectRatio=false, extent={{-100,-100},
{100,100}}), graphics));
end ChemicalReaction;
package MSL
"<html>Adapters to the <a href=\"modelica://Modelica\">Modelica Standard Library</a></html>"
extends Modelica.Icons.Package;
model Anode
"<html>Adapter between <a href=\"modelica://Modelica\">Modelica</a> and the boundary connector of a <a href=\"modelica://FCSys.Assemblies.Cells.Cell\">Cell</a>, <a href=\"modelica://FCSys.Regions.Region\">Region</a>, or <a href=\"modelica://FCSys.Subregions.Subregion\">Subregion</a></html>"
extends FCSys.Icons.Names.Top4;
replaceable package GasMedium = Media.AnodeGas constrainedby
Modelica.Media.Interfaces.PartialMedium "Medium model for the gas"
annotation (choicesAllMatching=true, Dialog(group=
"Material properties"));
replaceable package LiquidMedium =
Modelica.Media.Water.ConstantPropertyLiquidWater constrainedby
Modelica.Media.Interfaces.PartialMedium "Medium model for the liquid"
annotation (choicesAllMatching=true, Dialog(group=
"Material properties"));
Connectors.BoundaryBus boundary
"Multi-species connector for translational momentum and heat"
annotation (Placement(transformation(extent={{-50,-10},{-30,10}}),
iconTransformation(extent={{-50,-10},{-30,10}})));
Modelica.Fluid.Interfaces.FluidPort_b gasPort(redeclare final package
Medium = GasMedium) "Modelica fluid port for the gas" annotation (
Placement(transformation(extent={{50,50},{70,70}}),
iconTransformation(extent={{30,50},{50,70}})));
Modelica.Electrical.Analog.Interfaces.NegativePin pin
"Modelica electrical pin" annotation (Placement(transformation(extent
={{50,10},{70,30}}), iconTransformation(extent={{30,10},{50,30}})));
Modelica.Thermal.HeatTransfer.Interfaces.HeatPort_b heatPort
"Modelica heat port" annotation (Placement(transformation(extent={{50,
-30},{70,-10}}), iconTransformation(extent={{30,-30},{50,-10}})));
Modelica.Fluid.Interfaces.FluidPort_b liquidPort(redeclare final
package Medium = LiquidMedium) "Modelica fluid port for the liquid"
annotation (Placement(transformation(extent={{50,-70},{70,-50}}),
iconTransformation(extent={{30,-70},{50,-50}})));
Phases.AnodeGas gas(redeclare final package Medium = GasMedium)
"Gas subadapter"
annotation (Placement(transformation(extent={{-10,30},{10,50}})));
Phases.Graphite graphite('inclC+'=true, 'incle-'=true)
"Graphite subadapter"
annotation (Placement(transformation(extent={{-10,-10},{10,10}})));
Phases.Liquid liquid(redeclare final package Medium = LiquidMedium)
"Liquid subadapter"
annotation (Placement(transformation(extent={{-10,-50},{10,-30}})));
equation
connect(gas.boundary, boundary.gas) annotation (Line(
points={{-4,40},{-20,40},{-20,5.55112e-016},{-40,5.55112e-016}},
color={127,127,127},
thickness=0.5,
smooth=Smooth.None));
connect(gasPort, gas.fluidPort) annotation (Line(
points={{60,60},{30,60},{30,42},{4,42}},
color={0,127,255},
smooth=Smooth.None));
connect(gas.heatPort, heatPort) annotation (Line(
points={{4,38},{20,38},{20,-20},{60,-20}},
color={191,0,0},
smooth=Smooth.None));
connect(graphite.boundary, boundary.graphite) annotation (Line(
points={{-4,0},{-20,0},{-20,5.55112e-016},{-40,5.55112e-016}},
color={127,127,127},
smooth=Smooth.None,
thickness=0.5));
connect(graphite.pin, pin) annotation (Line(
points={{4,2},{30,2},{30,20},{60,20}},
color={0,0,255},
smooth=Smooth.None));
connect(graphite.heatPort, heatPort) annotation (Line(
points={{4,-2},{20,-2},{20,-20},{60,-20}},
color={191,0,0},
smooth=Smooth.None));
connect(liquid.boundary, boundary.liquid) annotation (Line(
points={{-4,-40},{-20,-40},{-20,5.55112e-016},{-40,5.55112e-016}},
color={127,127,127},
thickness=0.5,
smooth=Smooth.None));
connect(liquidPort, liquid.fluidPort) annotation (Line(
points={{60,-60},{30,-60},{30,-38},{4,-38}},
color={0,127,255},
smooth=Smooth.None));
connect(liquid.heatPort, heatPort) annotation (Line(
points={{4,-42},{20,-42},{20,-20},{60,-20}},
color={191,0,0},
smooth=Smooth.None));
annotation (Icon(coordinateSystem(preserveAspectRatio=false, extent={{-100,
-100},{100,100}}), graphics={Line(
points={{-40,0},{-20,0}},
color={127,127,127},
smooth=Smooth.None,
thickness=0.5),Line(
points={{0,60},{40,60}},
color={0,127,255},
smooth=Smooth.None),Line(
points={{-20,60},{-20,-60}},
color={127,127,127},
smooth=Smooth.None,
thickness=0.5),Line(
points={{0,-20},{40,-20}},
color={191,0,0},
smooth=Smooth.None),Polygon(
points={{0,0},{-20,-20},{0,-40},{20,-20},{0,0}},
lineColor={191,0,0},
smooth=Smooth.None,
fillColor={255,255,255},
fillPattern=FillPattern.Solid),Polygon(
points={{0,80},{-20,60},{0,40},{20,60},{0,80}},
lineColor={0,127,255},
smooth=Smooth.None,
fillColor={255,255,255},
fillPattern=FillPattern.Solid),Line(
points={{0,-60},{40,-60}},
color={0,127,255},
smooth=Smooth.None),Polygon(
points={{0,-40},{-20,-60},{0,-80},{20,-60},{0,-40}},
lineColor={0,127,255},
smooth=Smooth.None,
fillColor={255,255,255},
fillPattern=FillPattern.Solid),Line(
points={{10,20},{40,20}},
color={0,0,255},
visible='incle-',
smooth=Smooth.None),Polygon(
points={{0,40},{-20,20},{0,0},{20,20},{0,40}},
lineColor={0,0,255},
visible='incle-',
smooth=Smooth.None,
fillColor={255,255,255},
fillPattern=FillPattern.Solid),Text(
extent={{-20,-48},{20,-72}},
lineColor={127,127,127},
fillColor={255,255,255},
fillPattern=FillPattern.Solid,
textString="l"),Text(
extent={{-20,72},{20,48}},
lineColor={127,127,127},
fillColor={255,255,255},
fillPattern=FillPattern.Solid,
textString="g")}), Diagram(coordinateSystem(
preserveAspectRatio=false, extent={{-100,-100},{100,100}}),
graphics));
end Anode;
model Cathode
"<html>Adapter between <a href=\"modelica://Modelica\">Modelica</a> and the boundary connector of a <a href=\"modelica://FCSys.Assemblies.Cells.Cell\">Cell</a>, <a href=\"modelica://FCSys.Regions.Region\">Region</a>, or <a href=\"modelica://FCSys.Subregions.Subregion\">Subregion</a></html>"
extends FCSys.Icons.Names.Top4;
replaceable package GasMedium = Media.CathodeGas constrainedby
Modelica.Media.Interfaces.PartialMedium "Medium model for the gas"
annotation (choicesAllMatching=true, Dialog(group=
"Material properties"));
replaceable package LiquidMedium =
Modelica.Media.Water.ConstantPropertyLiquidWater constrainedby
Modelica.Media.Interfaces.PartialMedium "Medium model for the liquid"
annotation (choicesAllMatching=true, Dialog(group=
"Material properties"));
Connectors.BoundaryBus boundary
"Multi-species connector for translational momentum and heat"
annotation (Placement(transformation(extent={{-50,-10},{-30,10}}),
iconTransformation(extent={{-50,-10},{-30,10}})));
Modelica.Fluid.Interfaces.FluidPort_b gasPort(redeclare final package
Medium = GasMedium) "Modelica fluid port for the gas" annotation (
Placement(transformation(extent={{50,70},{70,90}}),
iconTransformation(extent={{30,50},{50,70}})));
Modelica.Electrical.Analog.Interfaces.NegativePin pin
"Modelica electrical pin" annotation (Placement(transformation(extent
={{50,30},{70,50}}), iconTransformation(extent={{30,10},{50,30}})));
Modelica.Thermal.HeatTransfer.Interfaces.HeatPort_b heatPort
"Modelica heat port" annotation (Placement(transformation(extent={{50,
-12},{70,8}}), iconTransformation(extent={{30,-30},{50,-10}})));
Modelica.Fluid.Interfaces.FluidPort_b liquidPort(redeclare final
package Medium = LiquidMedium) "Modelica fluid port for the liquid"
annotation (Placement(transformation(extent={{50,-48},{70,-28}}),
iconTransformation(extent={{30,-70},{50,-50}})));
Phases.CathodeGas gas(redeclare final package Medium = GasMedium)
"Gas subadapter"
annotation (Placement(transformation(extent={{-10,30},{10,50}})));
Phases.Graphite graphite('inclC+'=true, 'incle-'=true)
"Graphite subadapter"
annotation (Placement(transformation(extent={{-10,-10},{10,10}})));
Phases.Liquid liquid(redeclare final package Medium = LiquidMedium)
"Liquid subadapter"
annotation (Placement(transformation(extent={{-10,-50},{10,-30}})));
equation
connect(gas.boundary, boundary.gas) annotation (Line(
points={{-4,40},{-20,40},{-20,5.55112e-016},{-40,5.55112e-016}},
color={127,127,127},
thickness=0.5,
smooth=Smooth.None));
connect(gasPort, gas.fluidPort) annotation (Line(
points={{60,80},{30,80},{30,42},{4,42}},
color={0,127,255},
smooth=Smooth.None));
connect(gas.heatPort, heatPort) annotation (Line(
points={{4,38},{20,38},{20,-2},{60,-2}},
color={191,0,0},
smooth=Smooth.None));
connect(graphite.boundary, boundary.graphite) annotation (Line(
points={{-4,6.10623e-016},{-20,6.10623e-016},{-20,5.55112e-016},{-40,
5.55112e-016}},
color={127,127,127},
smooth=Smooth.None,
thickness=0.5));
connect(graphite.pin, pin) annotation (Line(
points={{4,2},{40,2},{40,40},{60,40}},
color={0,0,255},
smooth=Smooth.None));
connect(graphite.heatPort, heatPort) annotation (Line(
points={{4,-2},{60,-2}},
color={191,0,0},
smooth=Smooth.None));
connect(liquid.boundary, boundary.liquid) annotation (Line(
points={{-4,-40},{-20,-40},{-20,5.55112e-016},{-40,5.55112e-016}},
color={127,127,127},
thickness=0.5,
smooth=Smooth.None));
connect(liquidPort, liquid.fluidPort) annotation (Line(
points={{60,-38},{4,-38}},
color={0,127,255},
smooth=Smooth.None));
connect(liquid.heatPort, heatPort) annotation (Line(
points={{4,-42},{20,-42},{20,-2},{60,-2}},
color={191,0,0},
smooth=Smooth.None));
annotation (Icon(graphics={Line(
points={{-40,0},{-20,0}},
color={127,127,127},
smooth=Smooth.None,
thickness=0.5),Line(
points={{0,60},{40,60}},
color={0,127,255},
smooth=Smooth.None),Line(
points={{-20,60},{-20,-60}},
color={127,127,127},
smooth=Smooth.None,
thickness=0.5),Line(
points={{0,-20},{40,-20}},
color={191,0,0},
smooth=Smooth.None),Polygon(
points={{0,0},{-20,-20},{0,-40},{20,-20},{0,0}},
lineColor={191,0,0},
smooth=Smooth.None,
fillColor={255,255,255},
fillPattern=FillPattern.Solid),Polygon(
points={{0,80},{-20,60},{0,40},{20,60},{0,80}},
lineColor={0,127,255},
smooth=Smooth.None,
fillColor={255,255,255},
fillPattern=FillPattern.Solid),Line(
points={{0,-60},{40,-60}},
color={0,127,255},
smooth=Smooth.None),Polygon(
points={{0,-40},{-20,-60},{0,-80},{20,-60},{0,-40}},
lineColor={0,127,255},
smooth=Smooth.None,
fillColor={255,255,255},
fillPattern=FillPattern.Solid),Line(
points={{10,20},{40,20}},
color={0,0,255},
visible='incle-',
smooth=Smooth.None),Polygon(
points={{0,40},{-20,20},{0,0},{20,20},{0,40}},
lineColor={0,0,255},
visible='incle-',
smooth=Smooth.None,
fillColor={255,255,255},
fillPattern=FillPattern.Solid),Text(
extent={{-20,-48},{20,-72}},
lineColor={127,127,127},
fillColor={255,255,255},
fillPattern=FillPattern.Solid,
textString="l"),Text(
extent={{-20,72},{20,48}},
lineColor={127,127,127},
fillColor={255,255,255},
fillPattern=FillPattern.Solid,
textString="g")}), Diagram(coordinateSystem(
preserveAspectRatio=false, extent={{-100,-100},{100,100}}),
graphics));
end Cathode;
model Conductor
"<html>Adapter for electrical and thermal conduction between <a href=\"modelica://Modelica\">Modelica</a> and <a href=\"modelica://FCSys\">FCSys</a></html>"
extends FCSys.Icons.Names.Top2;
parameter Boolean 'inclC+'=false "Include C+" annotation (
HideResult=true,
choices(__Dymola_checkBox=true),
Dialog(
group="Species",
__Dymola_descriptionLabel=true,
__Dymola_label="<html>Carbon plus (C<sup>+</sup>)</html>"));
parameter Boolean 'incle-'=false "Include e-" annotation (
HideResult=true,
choices(__Dymola_checkBox=true),
Dialog(
group="Species",
__Dymola_descriptionLabel=true,
__Dymola_label="<html>Electrons (e<sup>-</sup>)</html>"));
Connectors.BoundaryBus boundary "Multi-species connector" annotation (
Placement(transformation(extent={{-50,-10},{-30,10}}),
iconTransformation(extent={{-50,-10},{-30,10}})));
Modelica.Electrical.Analog.Interfaces.NegativePin pin if 'incle-'
"Modelica electrical pin" annotation (Placement(transformation(extent
={{30,10},{50,30}}), iconTransformation(extent={{30,10},{50,30}})));
Phases.Graphite graphite(final 'inclC+'='inclC+', final 'incle-'=
'incle-') "Graphite subadapter"
annotation (Placement(transformation(extent={{-10,-10},{10,10}})));
Modelica.Thermal.HeatTransfer.Interfaces.HeatPort_b heatPort if
'inclC+' "Modelica heat port" annotation (Placement(transformation(
extent={{30,-30},{50,-10}}), iconTransformation(extent={{30,-30},
{50,-10}})));
equation
connect(graphite.boundary, boundary.graphite) annotation (Line(
points={{-4,6.10623e-016},{-40,6.10623e-016},{-40,0}},
color={127,127,127},
smooth=Smooth.None,
thickness=0.5));
connect(graphite.pin, pin) annotation (Line(
points={{4,2},{4,2},{20,2},{20,20},{40,20}},
color={0,0,255},
smooth=Smooth.None));
connect(graphite.heatPort, heatPort) annotation (Line(
points={{4,-2},{20,-2},{20,-20},{40,-20}},
color={191,0,0},
smooth=Smooth.None));
annotation (Icon(graphics={Line(
points={{0,20},{30,20}},
color={0,0,255},
visible='incle-',
smooth=Smooth.None),Line(
points={{-20,20},{-20,0}},
color={127,127,127},
visible='incle-',
smooth=Smooth.None),Line(
points={{-20,0},{-20,-20}},
color={127,127,127},
visible='inclC+',
smooth=Smooth.None),Line(
points={{0,-20},{30,-20}},
color={140,0,0},
visible='inclC+',
smooth=Smooth.None),Polygon(
points={{0,40},{-20,20},{0,0},{20,20},{0,40}},
lineColor={0,0,255},
visible='incle-',
smooth=Smooth.None,
fillColor={255,255,255},
fillPattern=FillPattern.Solid),Polygon(
points={{0,0},{-20,-20},{0,-40},{20,-20},{0,0}},
lineColor={140,0,0},
visible='inclC+',
smooth=Smooth.None,
fillColor={255,255,255},
fillPattern=FillPattern.Solid),Line(
points={{-30,0},{-20,0}},
color={127,127,127},
visible='incle-' or 'inclC+',
smooth=Smooth.None),Line(
points={{0,-20},{40,-20}},
color={140,0,0},
visible='inclC+',
smooth=Smooth.None),Line(
points={{10,20},{40,20}},
color={0,0,255},
visible='incle-',
smooth=Smooth.None),Polygon(
points={{0,0},{-20,-20},{0,-40},{20,-20},{0,0}},
lineColor={140,0,0},
visible='inclC+',
smooth=Smooth.None,
fillColor={255,255,255},
fillPattern=FillPattern.Solid),Polygon(
points={{0,40},{-20,20},{0,0},{20,20},{0,40}},
lineColor={0,0,255},
visible='incle-',
smooth=Smooth.None,
fillColor={255,255,255},
fillPattern=FillPattern.Solid),Line(
points={{-20,0},{-20,20}},
color={127,127,127},
smooth=Smooth.None,
thickness=0.5),Line(
points={{-20,-20},{-20,0}},
color={127,127,127},
smooth=Smooth.None,
thickness=0.5),Line(
points={{-40,0},{-20,0}},
color={127,127,127},
smooth=Smooth.None,
thickness=0.5)}));
end Conductor;
model Electronic
"<html>Adapter for e<sup>-</sup> between <a href=\"modelica://Modelica\">Modelica</a> and <a href=\"modelica://FCSys\">FCSys</a></html>"
extends FCSys.Icons.Names.Top1;
Connectors.BoundaryBus boundary "Multi-species connector" annotation (
Placement(transformation(extent={{-50,-10},{-30,10}}),
iconTransformation(extent={{-50,-10},{-30,10}})));
Modelica.Electrical.Analog.Interfaces.NegativePin pin
"Modelica electrical pin" annotation (Placement(transformation(extent
={{30,-10},{50,10}}), iconTransformation(extent={{30,-10},{50,
10}})));
Phases.Graphite graphite(final 'incle-'=true, final 'inclC+'=false)
"Graphite subadapter"
annotation (Placement(transformation(extent={{-10,-10},{10,10}})));
equation
connect(graphite.boundary, boundary.graphite) annotation (Line(
points={{-4,6.10623e-016},{-40,6.10623e-016},{-40,0}},
color={127,127,127},
smooth=Smooth.None,
thickness=0.5));
connect(graphite.pin, pin) annotation (Line(
points={{4,2},{4,0},{40,0}},
color={0,0,255},
smooth=Smooth.None));
annotation (Icon(graphics={Line(
points={{-30,0},{-20,0}},
color={127,127,127},
visible='incle-' or 'inclC+',
smooth=Smooth.None),Line(
points={{10,0},{40,0}},
color={0,0,255},
visible='incle-',
smooth=Smooth.None),Polygon(
points={{0,20},{-20,0},{0,-20},{20,0},{0,20}},
lineColor={0,0,255},
visible='incle-',
smooth=Smooth.None,
fillColor={255,255,255},
fillPattern=FillPattern.Solid),Line(
points={{-40,0},{-20,0}},
color={127,127,127},
smooth=Smooth.None,
thickness=0.5)}), Diagram(coordinateSystem(
preserveAspectRatio=false, extent={{-100,-100},{100,100}}),
graphics));
end Electronic;
package Phases "Adapters for material phases"
extends Modelica.Icons.Package;
model AnodeGas
"<html>Adapter for PEMFC anode gas between <a href=\"modelica://FCSys\">FCSys</a> and <a href=\"modelica://Modelica\">Modelica</a></html>"
extends FCSys.Icons.Names.Top2;
replaceable package Medium = Media.AnodeGas constrainedby
Modelica.Media.Interfaces.PartialMedium "Medium model (Modelica)"
annotation (choicesAllMatching=true, Dialog(group=
"Material properties"));
Domains.FluidNeutral H2(redeclare package Medium =
Modelica.Media.IdealGases.SingleGases.H2, redeclare package
Data = Characteristics.H2.Gas)
annotation (Placement(transformation(extent={{-10,10},{10,30}})));
Domains.FluidNeutral H2O(redeclare package Data =
Characteristics.H2O.Gas, redeclare final package Medium =
Modelica.Media.IdealGases.SingleGases.H2O)
annotation (Placement(transformation(extent={{-10,-30},{10,-10}})));
Junctions.Junction2 junction
annotation (Placement(transformation(extent={{46,30},{26,50}})));
Modelica.Fluid.Interfaces.FluidPort_b fluidPort(redeclare final
package Medium = Medium) "Modelica fluid port" annotation (
Placement(transformation(extent={{50,30},{70,50}}),
iconTransformation(extent={{30,10},{50,30}})));
Connectors.BoundaryBus boundary "FCSys boundary connector"
annotation (Placement(transformation(extent={{-50,-10},{-30,10}}),
iconTransformation(extent={{-50,-10},{-30,10}})));
Modelica.Thermal.HeatTransfer.Interfaces.HeatPort_b heatPort
"Modelica heat port" annotation (Placement(transformation(extent={{
50,-50},{70,-30}}), iconTransformation(extent={{30,-30},{50,
-10}})));
equation
// H2
connect(H2.boundary, boundary.H2) annotation (Line(
points={{-4,20},{-20,20},{-20,5.55112e-016},{-40,5.55112e-016}},
color={127,127,127},
smooth=Smooth.None));
connect(H2.heatPort, heatPort) annotation (Line(
points={{4,18},{40,18},{40,-40},{60,-40}},
color={191,0,0},
smooth=Smooth.None));
connect(H2.fluidPort, junction.purePort1) annotation (Line(
points={{4,22},{16,22},{16,44},{32,44}},
color={0,127,255},
smooth=Smooth.None));
// H2O
connect(H2O.boundary, boundary.H2O) annotation (Line(
points={{-4,-20},{-20,-20},{-20,5.55112e-016},{-40,5.55112e-016}},
color={127,127,127},
smooth=Smooth.None));
connect(H2O.heatPort, heatPort) annotation (Line(
points={{4,-22},{40,-22},{40,-40},{60,-40}},
color={191,0,0},
smooth=Smooth.None));
connect(H2O.fluidPort, junction.purePort2) annotation (Line(
points={{4,-18},{20,-18},{20,36},{32,36}},
color={0,127,255},
smooth=Smooth.None));
// Mixture
connect(junction.mixturePort, fluidPort) annotation (Line(
points={{40,40},{60,40}},
color={0,127,255},
smooth=Smooth.None));
annotation (Icon(graphics={Line(
points={{-40,0},{-20,0}},
color={127,127,127},
smooth=Smooth.None,
thickness=0.5),Line(
points={{0,20},{40,20}},
color={0,127,255},
smooth=Smooth.None),Line(
points={{-20,20},{-20,-20}},
color={127,127,127},
smooth=Smooth.None,
thickness=0.5),Line(
points={{0,-20},{40,-20}},
color={191,0,0},
smooth=Smooth.None),Polygon(
points={{0,0},{-20,-20},{0,-40},{20,-20},{0,0}},
lineColor={191,0,0},
smooth=Smooth.None,
fillColor={255,255,255},
fillPattern=FillPattern.Solid),Polygon(
points={{0,40},{-20,20},{0,0},{20,20},{0,40}},
lineColor={0,127,255},
smooth=Smooth.None,
fillColor={255,255,255},
fillPattern=FillPattern.Solid)}), Diagram(
coordinateSystem(preserveAspectRatio=false, extent={{-100,-100},
{100,100}}), graphics));
end AnodeGas;
model CathodeGas
"<html>Adapter for PEMFC cathode gas between <a href=\"modelica://FCSys\">FCSys</a> and <a href=\"modelica://Modelica\">Modelica</a></html>"
extends FCSys.Icons.Names.Top2;
replaceable package Medium = Media.CathodeGas constrainedby
Modelica.Media.Interfaces.PartialMedium "Medium model (Modelica)"
annotation (choicesAllMatching=true, Dialog(group=
"Material properties"));
Junctions.Junction3 junction(
redeclare package Medium1 =
Modelica.Media.IdealGases.SingleGases.H2O,
redeclare package Medium2 =
Modelica.Media.IdealGases.SingleGases.N2,
redeclare package Medium3 =
Modelica.Media.IdealGases.SingleGases.O2,
redeclare package MixtureMedium = Medium)
annotation (Placement(transformation(extent={{46,30},{26,50}})));
Domains.FluidNeutral H2O(redeclare package Data =
Characteristics.H2O.Gas, redeclare final package Medium =
Modelica.Media.IdealGases.SingleGases.H2O)
annotation (Placement(transformation(extent={{-10,10},{10,30}})));
Domains.FluidNeutral N2(redeclare package Data =
Characteristics.N2.Gas, redeclare final package Medium =
Modelica.Media.IdealGases.SingleGases.N2)
annotation (Placement(transformation(extent={{-10,-10},{10,10}})));
Domains.FluidNeutral O2(redeclare package Data =
Characteristics.O2.Gas, redeclare final package Medium =
Modelica.Media.IdealGases.SingleGases.O2)
annotation (Placement(transformation(extent={{-10,-30},{10,-10}})));
Modelica.Fluid.Interfaces.FluidPort_b fluidPort(redeclare final
package Medium = Medium) "Modelica fluid port" annotation (
Placement(transformation(extent={{50,30},{70,50}}),
iconTransformation(extent={{30,10},{50,30}})));
Connectors.BoundaryBus boundary
"FCSys boundary connector for shear force" annotation (Placement(
transformation(extent={{-50,-10},{-30,10}}), iconTransformation(
extent={{-50,-10},{-30,10}})));
Modelica.Thermal.HeatTransfer.Interfaces.HeatPort_b heatPort
"Modelica heat port" annotation (Placement(transformation(extent={{
50,-50},{70,-30}}), iconTransformation(extent={{30,-30},{50,
-10}})));
equation