Skip to content

Commit

Permalink
Remove file access from tests
Browse files Browse the repository at this point in the history
  • Loading branch information
braamvandyk committed Jul 13, 2024
1 parent afb5cfe commit 0cccd27
Show file tree
Hide file tree
Showing 13 changed files with 158 additions and 166 deletions.
28 changes: 28 additions & 0 deletions corrected.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
Timestamp,Ethylene,Ethane,Hydrogen,Nitrogen,Argon
2020/01/01 00:00,3.0083766913264873,26.835736901945783,0.0,0.0,0.0
2020/01/01 06:00,3.0122752167551723,26.963791743045917,0.0,0.0,0.0
2020/01/02 00:00,2.585930742198797,29.632356832198965,0.0,0.0,0.0
2020/01/02 06:00,2.9761703603631293,29.182702913216673,0.0,0.0,0.0
2020/01/03 00:00,2.9015044671522725,27.762081372179146,0.0,0.0,0.0
2020/01/03 06:00,2.874294992678864,28.53658904603999,0.0,0.0,0.0
2020/01/04 00:00,3.081113015029097,26.62348193331089,0.0,0.0,0.0
2020/01/04 06:00,3.049341758044824,27.193173419142095,0.0,0.0,0.0
2020/01/05 00:00,2.740714769461643,24.972745338141674,0.0,0.0,0.0
2020/01/05 06:00,2.886997138662742,29.430553417668566,0.0,0.0,0.0
2020/01/06 00:00,2.9150167837800343,26.17109933085312,0.0,0.0,0.0
2020/01/06 06:00,2.9643963478886994,26.113797068074483,0.0,0.0,0.0
2020/01/07 00:00,2.8012284010056714,24.825791865256555,0.0,0.0,0.0
2020/01/07 06:00,2.8073907754922063,27.751932941648906,0.0,0.0,0.0
2020/01/08 00:00,2.663511819024626,24.835621085404465,0.0,0.0,0.0
2020/01/08 06:00,2.698683941215198,29.69750257156399,0.0,0.0,0.0
2020/01/09 00:00,2.5848739576307316,26.734676897482224,0.0,0.0,0.0
2020/01/09 06:00,2.692180161717027,28.973112942338556,0.0,0.0,0.0
2020/01/10 00:00,3.0510497369050102,29.105783314192017,0.0,0.0,0.0
2020/01/10 06:00,2.7201007797438446,27.989192493038836,0.0,0.0,0.0
2020/01/11 00:00,2.6801400104303212,24.79772964635246,0.0,0.0,0.0
2020/01/11 06:00,2.8586606349089316,28.30425813181928,0.0,0.0,0.0
2020/01/12 00:00,3.0121363263515066,28.109514811425118,0.0,0.0,0.0
2020/01/12 06:00,2.8788586827937364,24.554236532004648,0.0,0.0,0.0
2020/01/13 00:00,2.7358116660981437,24.46065833659935,0.0,0.0,0.0
2020/01/13 06:00,3.058238037659462,25.23085988766036,0.0,0.0,0.0
2020/01/14 00:00,2.9887658768934973,25.705164750239195,0.0,0.0,0.0
54 changes: 27 additions & 27 deletions streamhistories/C2.csv
Original file line number Diff line number Diff line change
@@ -1,28 +1,28 @@
TimeStamp,Ethylene,Ethane,
2020/01/01 00:00,0.107239036,0.89247781,0.999716846
2020/01/01 06:00,0.107378006,0.896736538,1.004114544
2020/01/02 00:00,0.092180185,0.985485177,1.077665362
2020/01/02 06:00,0.106090983,0.970531008,1.076621991
2020/01/03 00:00,0.103429382,0.923285307,1.026714689
2020/01/03 06:00,0.102459451,0.949043158,1.051502609
2020/01/04 00:00,0.109831854,0.885418833,0.995250687
2020/01/04 06:00,0.10869931,0.904365099,1.013064409
2020/01/05 00:00,0.097697742,0.830520181,0.928217923
2020/01/05 06:00,0.102912242,0.978773788,1.08168603
2020/01/06 00:00,0.103911053,0.870373916,0.974284969
2020/01/06 06:00,0.105671277,0.868468211,0.974139488
2020/01/07 00:00,0.09985486,0.82563294,0.9254878
2020/01/07 06:00,0.100074529,0.9229478,1.023022329
2020/01/08 00:00,0.094945703,0.825959831,0.920905534
2020/01/08 06:00,0.096199477,0.987651733,1.08385121
2020/01/09 00:00,0.092142514,0.889116851,0.981259365
2020/01/09 06:00,0.095967638,0.963560661,1.059528299
2020/01/10 00:00,0.108760194,0.967972888,1.076733082
2020/01/10 06:00,0.096962919,0.930838356,1.027801275
2020/01/11 00:00,0.095538445,0.824699673,0.920238118
2020/01/11 06:00,0.101902136,0.941316514,1.04321865
2020/01/12 00:00,0.107373055,0.934839923,1.042212978
2020/01/12 06:00,0.102622132,0.816601807,0.919223939
2020/01/13 00:00,0.097522962,0.813489671,0.911012633
2020/01/13 06:00,0.109016434,0.839104313,0.948120747
2020/01/14 00:00,0.106539973,0.8548783,0.961418273
2020/01/01 00:00,0.107239036,0.89247781
2020/01/01 06:00,0.107378006,0.896736538
2020/01/02 00:00,0.092180185,0.985485177
2020/01/02 06:00,0.106090983,0.970531008
2020/01/03 00:00,0.103429382,0.923285307
2020/01/03 06:00,0.102459451,0.949043158
2020/01/04 00:00,0.109831854,0.885418833
2020/01/04 06:00,0.10869931,0.904365099
2020/01/05 00:00,0.097697742,0.830520181
2020/01/05 06:00,0.102912242,0.978773788
2020/01/06 00:00,0.103911053,0.870373916
2020/01/06 06:00,0.105671277,0.868468211
2020/01/07 00:00,0.09985486,0.82563294
2020/01/07 06:00,0.100074529,0.9229478
2020/01/08 00:00,0.094945703,0.825959831
2020/01/08 06:00,0.096199477,0.987651733
2020/01/09 00:00,0.092142514,0.889116851
2020/01/09 06:00,0.095967638,0.963560661
2020/01/10 00:00,0.108760194,0.967972888
2020/01/10 06:00,0.096962919,0.930838356
2020/01/11 00:00,0.095538445,0.824699673
2020/01/11 06:00,0.101902136,0.941316514
2020/01/12 00:00,0.107373055,0.934839923
2020/01/12 06:00,0.102622132,0.816601807
2020/01/13 00:00,0.097522962,0.813489671
2020/01/13 06:00,0.109016434,0.839104313
2020/01/14 00:00,0.106539973,0.8548783
28 changes: 28 additions & 0 deletions streamhistories/FeedStream.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
TimeStamp,Ethylene,Ethane,Hydrogen
2020/01/01 00:00,2.106769468,1.003401256,1.982216977
2020/01/01 06:00,2.131540904,1.013929486,2.060710012
2020/01/02 00:00,2.185135078,0.900772132,2.089783814
2020/01/02 06:00,2.121437851,0.996612314,1.949841967
2020/01/03 00:00,1.870060192,0.908472049,2.133315741
2020/01/03 06:00,2.162483792,1.017292333,1.981289862
2020/01/04 00:00,1.874144316,1.016528818,1.869917964
2020/01/04 06:00,1.930813671,0.987594037,2.057931188
2020/01/05 00:00,2.12724289,0.923263342,1.942614287
2020/01/05 06:00,2.166490061,1.09140564,2.103809748
2020/01/06 00:00,2.171592849,0.938031976,2.082197957
2020/01/06 06:00,1.804783711,1.009065835,2.174490206
2020/01/07 00:00,1.957542321,0.968165676,2.0137447
2020/01/07 06:00,2.090437725,0.959660933,1.981954587
2020/01/08 00:00,1.826464608,1.032311353,1.970649718
2020/01/08 06:00,2.0636046,0.929639599,1.981938883
2020/01/09 00:00,1.939313926,1.021765505,1.83542421
2020/01/09 06:00,1.812793332,1.014771253,2.025132329
2020/01/10 00:00,2.154109894,0.94432342,1.807169447
2020/01/10 06:00,2.046941449,1.072374428,2.04317426
2020/01/11 00:00,2.123098553,1.039538123,2.153854047
2020/01/11 06:00,2.164622176,0.924480721,1.844844328
2020/01/12 00:00,2.029604398,1.096570384,2.008174739
2020/01/12 06:00,1.812750071,0.93871181,2.080720078
2020/01/13 00:00,2.040306101,1.054645559,1.832314174
2020/01/13 06:00,1.825082427,1.086792417,1.870012827
2020/01/14 00:00,2.071117783,0.923618539,1.946087723
28 changes: 28 additions & 0 deletions streamhistories/ProdStream.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
TimeStamp,Ethylene,Ethane,Hydrogen
2020/01/01 00:00,0.094847475,2.824195924,0.107086839
2020/01/01 06:00,0.106695391,3.105880258,0.096251326
2020/01/02 00:00,0.102286352,2.930281896,0.092709887
2020/01/02 06:00,0.106366777,2.937360623,0.099469173
2020/01/03 00:00,0.10739573,3.079427009,0.107948161
2020/01/03 06:00,0.107216832,2.681132673,0.096722099
2020/01/04 00:00,0.108440593,3.147213457,0.09484186
2020/01/04 06:00,0.095783328,2.941535492,0.09831654
2020/01/05 00:00,0.096754576,2.859088923,0.101727602
2020/01/05 06:00,0.103450933,3.152374747,0.105715784
2020/01/06 00:00,0.103721975,3.165819875,0.108245492
2020/01/06 06:00,0.109647132,2.715473397,0.098381232
2020/01/07 00:00,0.097842428,2.974938255,0.097679239
2020/01/07 06:00,0.094613655,2.745158433,0.092714496
2020/01/08 00:00,0.105486247,3.046699336,0.102787767
2020/01/08 06:00,0.097740302,3.088488562,0.102170201
2020/01/09 00:00,0.109665602,3.150692658,0.099799808
2020/01/09 06:00,0.101942625,3.048766159,0.105441331
2020/01/10 00:00,0.097207081,2.850987559,0.098853211
2020/01/10 06:00,0.096770733,2.773339542,0.109027659
2020/01/11 00:00,0.109821635,2.941705012,0.090958608
2020/01/11 06:00,0.098911185,2.750565883,0.106860639
2020/01/12 00:00,0.106685906,2.89196396,0.093979461
2020/01/12 06:00,0.092178675,2.838049488,0.108714181
2020/01/13 00:00,0.09246444,3.08225984,0.104577241
2020/01/13 06:00,0.107521724,2.942532641,0.091441559
2020/01/14 00:00,0.105880929,2.76768405,0.100651375
7 changes: 0 additions & 7 deletions test/components/Ethane.comp

This file was deleted.

7 changes: 0 additions & 7 deletions test/components/Ethylene.comp

This file was deleted.

5 changes: 0 additions & 5 deletions test/components/Hydrogen.comp

This file was deleted.

5 changes: 0 additions & 5 deletions test/components/argon.comp

This file was deleted.

5 changes: 0 additions & 5 deletions test/components/nitrogen.comp

This file was deleted.

73 changes: 47 additions & 26 deletions test/runtests.jl
Original file line number Diff line number Diff line change
@@ -1,44 +1,36 @@
using FlowsheetTools
using Test

@testset "Streams" begin
@testset "Components and Streams" begin
fs = Flowsheet()

@comp begin
"C" --> 2
"H" --> 4
end "Ethylene" fs
dummy = writecomponent(joinpath(@__DIR__, "components", "Ethylene.comp"), fs.comps["Ethylene"])
@test dummy == 25

@comp begin
"C" --> 2
"H" --> 6
end "Ethane" fs
dummy = writecomponent(joinpath(@__DIR__, "components", "Ethane.comp"), fs.comps["Ethane"])
@test dummy == 24

@comp begin
"H" --> 2
end "Hydrogen" fs
dummy = writecomponent(joinpath(@__DIR__, "components", "Hydrogen.comp"), fs.comps["Hydrogen"])
@test dummy == 21

@comp begin
"N" --> 2
end "Nitrogen" fs
dummy = writecomponent(joinpath(@__DIR__, "components", "Nitrogen.comp"), fs.comps["Nitrogen"])
@test dummy == 22

@comp begin
"Ar" --> 1
end "Argon" fs
dummy = writecomponent(joinpath(@__DIR__, "components", "Argon.comp"), fs.comps["Argon"])
@test dummy == 19

count = readcomponentlist!(fs, joinpath(@__DIR__, "components"), ["Ethylene", "Ethane", "Hydrogen"])
@test count == 3
@test fs.comps["Ethylene"].Mr 28.053
@test fs.comps["Ethane"].Mr 30.0688
@test fs.comps["Hydrogen"].Mr 2.0158
@test fs.comps["Nitrogen"].Mr 28.0134
@test fs.comps["Argon"].Mr 39.948


@stream mass begin
Expand Down Expand Up @@ -67,7 +59,7 @@ using Test
@test all(values(fs.streams["Prod2"].totalmassflow .≈ 2.0 .* fs.streams["Product"].totalmassflow))
end

@testset "UnitOps and Boundaries" begin
@testset "Simple UnitOps and Boundaries" begin
fs = Flowsheet()

@comp begin
Expand Down Expand Up @@ -142,15 +134,46 @@ end
@test molar_selectivity(fs.boundaries["B"], "Ethylene", "Ethane") 1.0
end

@testset "Corrections and Closure" begin
@testset "Active UnitOps and Closures" begin
fs = Flowsheet()

count = readcomponentlist!(fs, joinpath(@__DIR__, "components"), ["Ethylene", "Ethane", "Hydrogen", "Nitrogen", "Argon"])
@test count ==5
@comp begin
"C" --> 2
"H" --> 4
end "Ethylene" fs

@comp begin
"C" --> 2
"H" --> 6
end "Ethane" fs

@comp begin
"H" --> 2
end "Hydrogen" fs

@comp begin
"N" --> 2
end "Nitrogen" fs

@comp begin
"Ar" --> 1
end "Argon" fs

@stream mole begin
"Ethylene" --> 0.1
"Ethane" --> 0.9
end "C2" fs

@stream mole begin
"Hydrogen" --> 1.1
end "H2" fs

@stream mole begin
"Ethylene" --> 0.0
"Ethane" --> 1.0
"Hydrogen" --> 1.0
end "Product" fs

readstreamhistory!(fs, "C2", joinpath(@__DIR__, "streamhistories", "C2.csv"); ismoleflow=true)
readstreamhistory!(fs, "H2", joinpath(@__DIR__, "streamhistories", "Hydrogen.csv"); ismoleflow=true)
readstreamhistory!(fs, "Product", joinpath(@__DIR__, "streamhistories", "Product.csv"); ismoleflow=true)
addemptystream!(fs, "Mixed");
addemptystream!(fs, "Product1");
addemptystream!(fs, "Product1a");
Expand Down Expand Up @@ -219,13 +242,11 @@ end
end "Reactor2" fs
fs.unitops["Reactor2"]()

a = values(fs.streams["Product4"].moleflows[Symbol("Ethylene")] .≈ fs.streams["Product4"].moleflows[Symbol("Ethane")])
@test findall(<(1), a) == [9, 13, 14, 18]
@test all(values(fs.streams["Product4"].moleflows[Symbol("Ethylene")] .≈ fs.streams["Product4"].moleflows[Symbol("Ethane")]))


fs.streams["Mixed"] = 1.1*fs.streams["Mixed"]



@boundary begin
unitops --> ["Mixer"]
end "B1" fs
Expand All @@ -242,6 +263,6 @@ end

closemb!(fs, corrections)

sum(values(fs.boundaries["B1"].closure)) 27
sum(values(fs.boundaries["B2"].closure)) 27
@test all(values(fs.boundaries["B1"].closure) .≈ 1)
@test all(values(fs.boundaries["B2"].closure) .≈ 1)
end
28 changes: 0 additions & 28 deletions test/streamhistories/C2.csv

This file was deleted.

28 changes: 0 additions & 28 deletions test/streamhistories/Hydrogen.csv

This file was deleted.

Loading

0 comments on commit 0cccd27

Please sign in to comment.