Getting started

To solve ADM1 for a single tank reactor, just run ADM1sol. For multiple tanks running in parallel, use multichamberSolution

Installation

To install ADM1jl open the Julia REPL and run the following:

julia> using Pkg
julia> Pkg.add(url="https://github.com/CourtA96/ADM1jl")

OR enter the Pkg REPL by pressing ] and running:

add https://github.com/CourtA96/ADM1jl

Then, to use the package, run

julia> using ADM1jl

Basic Usage

Before beginning, make sure that the file model_parameters.csv is saved in your working directory. model_parameters.csv can be found on the github here.

ADM1sol takes the timespan, initial conditions, and inflow vector as inputs. The timespan is length 2 and type Tuple{Float64}. It specifies how the initial and final times of the simulation. The initial conditions and inflow vector both have type Vector{Float64} and length 35. To test this out, run the following code:

julia> using ADM1jl
julia> u0 = initialConditions(); # assigns the default initial conditions to u0
julia> IV = inflowvector_definition(); # assigns the default inflow vector to IV
julia> tspan = (0.0,200.0); # the solution will be computed from t=0.0 to t=200.0
julia> sol, tSol = ADM1sol(tspan,u0,IV); # computes the solution and saves it to sol, the time to solve is saved to tSol
julia> sol # the solution has two fields: t contains the timesteps and u contains the solution at each timestepretcode: Success Interpolation: specialized 3rd order "free" stiffness-aware interpolation t: 115-element Vector{Float64}: 0.0 1.998068760796162e-5 3.341468554331606e-5 3.988122832624887e-5 4.4680235201568236e-5 4.794627727453984e-5 5.0952331938662506e-5 5.362905748672321e-5 5.577698080992574e-5 5.59591935316201e-5 ⋮ 8.609164585998075 11.792384122076196 17.23534599428072 27.65259736037021 40.9934159708475 60.77931802713721 89.13707315427706 133.678905885535 200.0 u: 115-element Vector{Vector{Float64}}: [0.012, 0.0053, 0.099, 0.012, 0.013, 0.016, 0.2, 2.3e-7, 0.055, 0.15 … 0.013, 0.016, 0.2, 0.14, 0.0041, 0.04, 0.02, 1.02e-5, 1.63, 0.014] [0.011999986305998722, 0.005299528080754454, 0.09899995851630547, 0.011999757994309943, 0.013000244814496508, 0.015999974836690346, 0.19999987668832014, 2.3401029375177689e-7, 0.05500093731160939, 0.15000108782030885 … 0.013000159436964311, 0.015999970507271203, 0.19999977215565246, 0.14093963528890685, 0.004127911003920925, 0.04, 0.02, 1.0200056486177253e-5, 1.6300010043803432, 0.013987846051651676] [0.011999977102201841, 0.005299211849244109, 0.09899993070591713, 0.011999595199349622, 0.013000409099486977, 0.015999957894011495, 0.19999984913764737, 2.3462131401959785e-7, 0.05500151446755541, 0.15000380034967298 … 0.013000313521295812, 0.015999946335854873, 0.19999964945541363, 0.1415212292753339, 0.004146669662439726, 0.04, 0.02, 1.0200111031499442e-5, 1.630003893522008, 0.01395723325778608] [0.01199997267285494, 0.005299059933102669, 0.09899991732837085, 0.011999516807541343, 0.013000488081982675, 0.015999949717195445, 0.19999985166543557, 2.347293069533868e-7, 0.055001776916148076, 0.15000562388554228 … 0.013000386918303651, 0.015999931239462844, 0.19999957058322893, 0.1417877072042461, 0.00415569574693518, 0.04, 0.02, 1.0200145033126272e-5, 1.6300064891566448, 0.013936637777305555] [0.011999969386113186, 0.005298947319276687, 0.09899990740392622, 0.011999458618243508, 0.013000546656182773, 0.015999943639550377, 0.19999986014700516, 2.3474406467471658e-7, 0.055001965283821, 0.1500071824509174 … 0.013000438625344519, 0.015999916159724275, 0.19999947696986942, 0.14197999936663422, 0.0041623915318146935, 0.04, 0.02, 1.0200174359689561e-5, 1.6300090584027846, 0.013919032066060481] [0.011999967149464337, 0.005298870740171685, 0.09899990065057425, 0.011999419010167864, 0.013000586499471117, 0.015999939497968046, 0.19999986913024304, 2.3474522959959367e-7, 0.05500209036090212, 0.15000833975670527 … 0.013000470481880305, 0.015999901501279105, 0.19999936812481842, 0.1421082301384086, 0.004166946010324206, 0.04, 0.02, 1.0200196512193376e-5, 1.630011157417349, 0.013905958298756526] [0.011999965091000644, 0.005298800301401363, 0.09899989443528127, 0.011999382550373399, 0.013000623156476359, 0.015999935682081648, 0.19999987969147337, 2.3474488799855715e-7, 0.055002203256657285, 0.15000947223645938 … 0.013000493702415057, 0.01599988011394127, 0.19999918140535206, 0.14222433850204402, 0.004171134331226857, 0.04, 0.02, 1.0200218587470163e-5, 1.630013359837308, 0.01389316476641871] [0.011999963258166062, 0.005298737615364131, 0.09899988890125047, 0.01199935008118014, 0.01300065578569865, 0.01599993228099467, 0.19999989094073073, 2.347444987540964e-7, 0.05500230199803541, 0.15001053370926534 … 0.01300049826251715, 0.015999840500626243, 0.19999877915797137, 0.14232604017076153, 0.004174856025265061, 0.04, 0.02, 1.0200239681291e-5, 1.6300155516628245, 0.013881173393149072] [0.01199996178749697, 0.005298687337685513, 0.09899988446073249, 0.011999324023898476, 0.01300068196078733, 0.01599992954959562, 0.1999999012174798, 2.3474418112539864e-7, 0.05500238002558099, 0.15001142074354162 … 0.013000388322034054, 0.015999666872248287, 0.19999673918914604, 0.1424052653887559, 0.004177800388075795, 0.04, 0.02, 1.02002576323418e-5, 1.6300174749013072, 0.013871152739877324] [0.011999961662742068, 0.005298683073531872, 0.09899988408404545, 0.011999321813301279, 0.013000684180943878, 0.01599992931779467, 0.1999999021395164, 2.347441524718461e-7, 0.055002386596366144, 0.15001149737441244 … 0.013000321279075213, 0.015999580623548823, 0.19999568545398935, 0.14241127765294348, 0.004178030475579708, 0.04, 0.02, 1.0200259198299479e-5, 1.6300176449752604, 0.013870287064082722] ⋮ [0.011957024281388772, 0.005313145376836529, 0.09946648787238688, 0.011654600434373587, 0.013284591926146994, 0.015582479107210874, 0.19687288370645853, 2.3471110437262594e-7, 0.055090582310417024, 0.15254315137788282 … 0.013254497202185777, 0.015542110712389683, 0.1964857276371254, 0.14264329781345514, 0.004079056450750521, 0.04, 0.02, 1.018738960428329e-5, 1.6256583127128807, 0.014149764848711631] [0.01195654102848209, 0.005313458937485294, 0.09929418665370938, 0.01164865507208881, 0.013277787588848837, 0.015622266425532707, 0.1969233866233376, 2.3495538589926901e-7, 0.05508947273111594, 0.15256470528506616 … 0.01324771163060618, 0.015581799489349265, 0.19653617435469634, 0.14266448807174104, 0.004080233092909001, 0.04, 0.02, 1.0198005071695315e-5, 1.6256250660754588, 0.01415028486767014] [0.011955980109704207, 0.00531386295705003, 0.09907802169827609, 0.011641137972864016, 0.01326918658109571, 0.01567308648104798, 0.19702187144497735, 2.352672348101359e-7, 0.055089337416742594, 0.1525933902838197 … 0.013239136031666108, 0.015632495938305287, 0.1966345420022493, 0.14269314307170092, 0.004082029933356304, 0.04, 0.02, 1.0211565080365322e-5, 1.625621749084325, 0.014150328062007254] [0.011955371939386264, 0.0053143158605383585, 0.09883944038665217, 0.011632771464264816, 0.013259614089760997, 0.015730175804749624, 0.1971596873487173, 2.3561696730430503e-7, 0.05508926775843366, 0.15263045101863412 … 0.013229592968515834, 0.01568944795667104, 0.19677218711874223, 0.14273019624934105, 0.004084370204919226, 0.04, 0.02, 1.0226772178030066e-5, 1.625620443499663, 0.01415033918241631] [0.011955036272014314, 0.0053145727297110815, 0.0987062051950052, 0.011628053850075558, 0.013254216446260576, 0.015762608072920514, 0.1972650063546642, 2.358156012903638e-7, 0.05508923137310232, 0.15265675340982643 … 0.01322421304832514, 0.015721803754039324, 0.19687737030075056, 0.14275649532397347, 0.004086034426312779, 0.04, 0.02, 1.0235409193646683e-5, 1.6256197935003422, 0.014150344102072282] [0.011954879037458292, 0.005314697865111298, 0.09864241740321439, 0.011625770979812398, 0.01325160448275435, 0.01577837229712297, 0.197339362116905, 2.3591236791138904e-7, 0.05508921431514828, 0.1526741080818041 … 0.013221610629336295, 0.015737532123255283, 0.19695162694908167, 0.1427738486162467, 0.004087134222202541, 0.04, 0.02, 1.0239616823376926e-5, 1.6256194976733636, 0.014150346161797715] [0.011954836213455822, 0.00531473416356305, 0.09862432560165917, 0.011625114587568658, 0.013250853454556363, 0.01578291681184238, 0.19737459437098553, 2.3594040068890368e-7, 0.05508920948740529, 0.15268186309600545 … 0.013220862924643861, 0.01574206708874299, 0.19698681099245025, 0.14278160328937375, 0.0040876262817559055, 0.04, 0.02, 1.024083576246797e-5, 1.6256194164919724, 0.014150346675181056] [0.011954830158706282, 0.0053147398286552405, 0.09862158138802907, 0.01162501321766733, 0.013250737466870395, 0.015783619896173714, 0.1973850412510544, 2.3594476937421984e-7, 0.05508920874769569, 0.15268406799526774 … 0.013220747661280148, 0.015742768982620215, 0.1969972433244719, 0.14278380814515448, 0.004087766294494727, 0.04, 0.02, 1.0241025727130154e-5, 1.6256194045086088, 0.014150346741486993] [0.011954829810563401, 0.0053147401832121036, 0.09862141249882697, 0.011625006887037806, 0.013250730223207484, 0.015783663823179507, 0.19738633671962316, 2.3594504387169125e-7, 0.05508920869990237, 0.15268433594303998 … 0.013220740490142689, 0.015742812872396397, 0.1969985369743189, 0.1427840760901829, 0.004087783314163287, 0.04, 0.02, 1.0241037663368444e-5, 1.6256194037384155, 0.014150346745679485]
julia> tSol # this is the time ExampleSol took to solve the system32.4064007

To save solutions at specific times, use the saveAt keyword argument. It takes either a vector of times to stop, or a number n that tells the solver to save solution every n timesteps. For example:

julia> using ADM1jl
julia> u0 = initialConditions(); # assigns the default initial conditions to u0
julia> IV = inflowvector_definition(); # assigns the default inflow vector to IV
julia> tspan = (0.0,200.0); # the solution will be computed from t=0.0 to t=200.0
julia> sol2, tSol2 = ADM1sol(tspan,u0,IV,saveAt=[10.0,15.0,50.0,100.0,150.0,200.0]); # save the solution at 10 days, 15 days, 50 days and so on.
julia> sol3, tSol3 = ADM1sol(tspan,u0,IV,saveAt=5.0); # save the solution every 5 days

Modifying Parameters

To change the system parameters, such as T_base or P_atm, just open the file model_parameters.csv in your working directory (model_parameters.csv can be found here). Edit whichever entries are necessary, save, and exit. Running ADM1sol again will solve the system with the updated parameters.

Specifying Alorithms

By default, ADM1sol solves the system using the Rodas4P algorithm given in the DifferentialEquations package (documentation for DifferentialEquations available here). To use a different algorithm, install the DifferentialEquations package and follow the example below:

julia> using DifferentialEquations
julia> using ADM1jl
julia> u0 = initialConditions();
julia> IV = inflowvector_definition();
julia> sol,tSol = ADM1sol((0.0,50.0),u0,IV, alg = Rosenbrock23()); # solve the system using the Rosenbrock23 algorithm

In principle, any ODE solver listed in the DifferentialEquations documentation can be used to solve the system. However, ADM1 is a stiff system of equations, so many solvers may not be stable.

Variable Inflow

To solve the system for variable inflow, specify the inflow as a Vector{Vector{Float}}, ie. as a vector that contains the vector of inflow conditions at a different times, these times are indexed by an additional input vector t.

The ADM1sol function interpolates the function using the interpolate function from the Interpolations package (documentation for Interpolations available here). The Gridded(Linear()) interpolation algorithm is specified, meaning that the interpolation between timesteps is linear. Interpolation allows for the use of adaptive step methods, which are more stable than fixed stepsize methods. As when the inflow is fixed, the default solver algorithm is Rodas4P.

The following code breaks the timespan into 0.1 day increments and then randomizes the inflow concentrations within 50 percent of the default values every 0.1 days. The system is then solved for these randomly varied inflow vectors.

julia> using ADM1jl
julia> u0 = initialConditions(); # the default initial conditions
julia> tspan = (0.0,50.0); # The timespan of the solution is 50 days
julia> t = [i for i in tspan[1]:0.1:tspan[2]]; # Break the timespan into 0.1 day increments
julia> IV_temp = inflowvector_definition(); # temporary inflow vector
julia> IV = [IV_temp*(0.5*rand()+1.0) for i in 1:length(t)] # for each time in t, vary the inflow concentrations within 50 percent of their default values501-element Vector{Vector{Float64}}: [0.014215436896168474, 0.0014215436896168475, 0.0014215436896168475, 0.0014215436896168475, 0.0014215436896168475, 0.0014215436896168475, 0.0014215436896168475, 1.4215436896168475e-8, 1.4215436896168476e-5, 0.0568617475846739 … 0.0, 0.0, 0.0, 0.0, 0.0, 0.0568617475846739, 0.02843087379233695, 0.0, 0.0, 0.0] [0.0145496650969872, 0.0014549665096987199, 0.0014549665096987199, 0.0014549665096987199, 0.0014549665096987199, 0.0014549665096987199, 0.0014549665096987199, 1.4549665096987198e-8, 1.45496650969872e-5, 0.0581986603879488 … 0.0, 0.0, 0.0, 0.0, 0.0, 0.0581986603879488, 0.0290993301939744, 0.0, 0.0, 0.0] [0.01228631457555288, 0.001228631457555288, 0.001228631457555288, 0.001228631457555288, 0.001228631457555288, 0.001228631457555288, 0.001228631457555288, 1.228631457555288e-8, 1.228631457555288e-5, 0.04914525830221152 … 0.0, 0.0, 0.0, 0.0, 0.0, 0.04914525830221152, 0.02457262915110576, 0.0, 0.0, 0.0] [0.014380204250809396, 0.0014380204250809398, 0.0014380204250809398, 0.0014380204250809398, 0.0014380204250809398, 0.0014380204250809398, 0.0014380204250809398, 1.4380204250809396e-8, 1.4380204250809398e-5, 0.057520817003237586 … 0.0, 0.0, 0.0, 0.0, 0.0, 0.057520817003237586, 0.028760408501618793, 0.0, 0.0, 0.0] [0.01433907213126703, 0.001433907213126703, 0.001433907213126703, 0.001433907213126703, 0.001433907213126703, 0.001433907213126703, 0.001433907213126703, 1.433907213126703e-8, 1.4339072131267032e-5, 0.05735628852506812 … 0.0, 0.0, 0.0, 0.0, 0.0, 0.05735628852506812, 0.02867814426253406, 0.0, 0.0, 0.0] [0.01488131216686139, 0.0014881312166861388, 0.0014881312166861388, 0.0014881312166861388, 0.0014881312166861388, 0.0014881312166861388, 0.0014881312166861388, 1.4881312166861389e-8, 1.488131216686139e-5, 0.05952524866744556 … 0.0, 0.0, 0.0, 0.0, 0.0, 0.05952524866744556, 0.02976262433372278, 0.0, 0.0, 0.0] [0.013086873117355166, 0.0013086873117355167, 0.0013086873117355167, 0.0013086873117355167, 0.0013086873117355167, 0.0013086873117355167, 0.0013086873117355167, 1.3086873117355167e-8, 1.3086873117355167e-5, 0.052347492469420664 … 0.0, 0.0, 0.0, 0.0, 0.0, 0.052347492469420664, 0.026173746234710332, 0.0, 0.0, 0.0] [0.010203926977929424, 0.0010203926977929423, 0.0010203926977929423, 0.0010203926977929423, 0.0010203926977929423, 0.0010203926977929423, 0.0010203926977929423, 1.0203926977929423e-8, 1.0203926977929424e-5, 0.040815707911717694 … 0.0, 0.0, 0.0, 0.0, 0.0, 0.040815707911717694, 0.020407853955858847, 0.0, 0.0, 0.0] [0.010226925327065935, 0.0010226925327065934, 0.0010226925327065934, 0.0010226925327065934, 0.0010226925327065934, 0.0010226925327065934, 0.0010226925327065934, 1.0226925327065934e-8, 1.0226925327065935e-5, 0.04090770130826374 … 0.0, 0.0, 0.0, 0.0, 0.0, 0.04090770130826374, 0.02045385065413187, 0.0, 0.0, 0.0] [0.010294257219497057, 0.0010294257219497056, 0.0010294257219497056, 0.0010294257219497056, 0.0010294257219497056, 0.0010294257219497056, 0.0010294257219497056, 1.0294257219497056e-8, 1.0294257219497056e-5, 0.04117702887798823 … 0.0, 0.0, 0.0, 0.0, 0.0, 0.04117702887798823, 0.020588514438994114, 0.0, 0.0, 0.0] ⋮ [0.012085235368485134, 0.0012085235368485135, 0.0012085235368485135, 0.0012085235368485135, 0.0012085235368485135, 0.0012085235368485135, 0.0012085235368485135, 1.2085235368485134e-8, 1.2085235368485136e-5, 0.04834094147394054 … 0.0, 0.0, 0.0, 0.0, 0.0, 0.04834094147394054, 0.02417047073697027, 0.0, 0.0, 0.0] [0.010125976729854226, 0.0010125976729854224, 0.0010125976729854224, 0.0010125976729854224, 0.0010125976729854224, 0.0010125976729854224, 0.0010125976729854224, 1.0125976729854225e-8, 1.0125976729854225e-5, 0.0405039069194169 … 0.0, 0.0, 0.0, 0.0, 0.0, 0.0405039069194169, 0.02025195345970845, 0.0, 0.0, 0.0] [0.013246816464765441, 0.001324681646476544, 0.001324681646476544, 0.001324681646476544, 0.001324681646476544, 0.001324681646476544, 0.001324681646476544, 1.3246816464765442e-8, 1.3246816464765442e-5, 0.052987265859061765 … 0.0, 0.0, 0.0, 0.0, 0.0, 0.052987265859061765, 0.026493632929530882, 0.0, 0.0, 0.0] [0.01029679900233106, 0.0010296799002331059, 0.0010296799002331059, 0.0010296799002331059, 0.0010296799002331059, 0.0010296799002331059, 0.0010296799002331059, 1.029679900233106e-8, 1.029679900233106e-5, 0.04118719600932424 … 0.0, 0.0, 0.0, 0.0, 0.0, 0.04118719600932424, 0.02059359800466212, 0.0, 0.0, 0.0] [0.013632709572002766, 0.0013632709572002767, 0.0013632709572002767, 0.0013632709572002767, 0.0013632709572002767, 0.0013632709572002767, 0.0013632709572002767, 1.3632709572002766e-8, 1.3632709572002768e-5, 0.054530838288011065 … 0.0, 0.0, 0.0, 0.0, 0.0, 0.054530838288011065, 0.027265419144005532, 0.0, 0.0, 0.0] [0.012348873729452672, 0.0012348873729452672, 0.0012348873729452672, 0.0012348873729452672, 0.0012348873729452672, 0.0012348873729452672, 0.0012348873729452672, 1.2348873729452672e-8, 1.2348873729452673e-5, 0.04939549491781069 … 0.0, 0.0, 0.0, 0.0, 0.0, 0.04939549491781069, 0.024697747458905343, 0.0, 0.0, 0.0] [0.013803311370665617, 0.0013803311370665617, 0.0013803311370665617, 0.0013803311370665617, 0.0013803311370665617, 0.0013803311370665617, 0.0013803311370665617, 1.3803311370665616e-8, 1.3803311370665618e-5, 0.05521324548266247 … 0.0, 0.0, 0.0, 0.0, 0.0, 0.05521324548266247, 0.027606622741331233, 0.0, 0.0, 0.0] [0.01486547796348729, 0.001486547796348729, 0.001486547796348729, 0.001486547796348729, 0.001486547796348729, 0.001486547796348729, 0.001486547796348729, 1.4865477963487291e-8, 1.4865477963487291e-5, 0.05946191185394916 … 0.0, 0.0, 0.0, 0.0, 0.0, 0.05946191185394916, 0.02973095592697458, 0.0, 0.0, 0.0] [0.012198854744780035, 0.0012198854744780035, 0.0012198854744780035, 0.0012198854744780035, 0.0012198854744780035, 0.0012198854744780035, 0.0012198854744780035, 1.2198854744780035e-8, 1.2198854744780035e-5, 0.04879541897912014 … 0.0, 0.0, 0.0, 0.0, 0.0, 0.04879541897912014, 0.02439770948956007, 0.0, 0.0, 0.0]
julia> sol,tSol = ADM1sol((0.0,50.0),u0,IV,t); # solve the system
julia> sol # The solutionretcode: Success Interpolation: specialized 3rd order "free" stiffness-aware interpolation t: 863-element Vector{Float64}: 0.0 1.998082026888981e-5 3.341487748917039e-5 3.98812762889316e-5 4.4680407974299816e-5 4.7946518577137976e-5 5.095262797386422e-5 5.362944745147952e-5 5.5777523310823906e-5 5.5959686136593374e-5 ⋮ 49.57089099992352 49.63439933295696 49.665364631864925 49.74211674726509 49.77914599012151 49.885452597744916 49.93669245024191 49.97836694243118 50.0 u: 863-element Vector{Vector{Float64}}: [0.012, 0.0053, 0.099, 0.012, 0.013, 0.016, 0.2, 2.3e-7, 0.055, 0.15 … 0.013, 0.016, 0.2, 0.14, 0.0041, 0.04, 0.02, 1.02e-5, 1.63, 0.014] [0.011999990737160368, 0.005299529338292596, 0.09899995913696123, 0.011999758414150253, 0.013000245237740463, 0.01599997525794536, 0.19999987711018216, 2.3401031871031797e-7, 0.055000937322130704, 0.15000110465306865 … 0.013000159729461195, 0.0159999707819228, 0.19999977246253334, 0.14093964202942766, 0.004127911189696274, 0.04000001684570242, 0.02000000842285121, 1.020005648700346e-5, 1.6300010043790043, 0.013987846199041433] [0.011999984759781661, 0.005299214894873699, 0.09899993196855196, 0.011999595902599369, 0.013000409807954876, 0.015999958598962666, 0.19999984984601293, 2.3462136047080466e-7, 0.05500151448375009, 0.15000382848350016 … 0.013000314090832766, 0.01599994688321267, 0.19999965004331585, 0.14152123951550724, 0.004146669931873502, 0.04000002817201114, 0.02000001408600557, 1.0200111033448761e-5, 1.6300038935079169, 0.013957233690971746] [0.011999981954377903, 0.005299064112761857, 0.0989999189647581, 0.011999517649664945, 0.01300048892609448, 0.015999950559081398, 0.19999985251250793, 2.347293665148896e-7, 0.055001776928263996, 0.15000565740131822 … 0.013000387622761607, 0.01599993192277333, 0.19999957131383286, 0.14178771225797746, 0.00415569581608576, 0.040000033623898784, 0.020000016811949392, 1.0200145034856856e-5, 1.6300064890486052, 0.013936639000858194] [0.011999979902451574, 0.0052989524480857786, 0.09899990934426753, 0.01199945956081657, 0.013000547604029841, 0.015999944582849125, 0.1999998610977021, 2.3474413443852601e-7, 0.05500196530225145, 0.1500072200276481 … 0.013000439433282539, 0.01599991694420964, 0.19999947780693764, 0.14198001008577227, 0.004162391775834203, 0.04000003767011323, 0.020000018835056615, 1.0200174362645152e-5, 1.6300090583235347, 0.013919033123428433] [0.01199997852067188, 0.005298876570305741, 0.098999902810987, 0.011999420021405553, 0.013000587517842886, 0.015999940510345805, 0.1999998701518074, 2.3474530698708992e-7, 0.05500209038289259, 0.15000838009445516 … 0.013000471360489638, 0.01599990235513949, 0.1999993690385352, 0.14210824398960406, 0.004166946350579142, 0.0400000404238246, 0.0200000202119123, 1.0200196516013161e-5, 1.6300111573591927, 0.013905959273766472] [0.011999977259399764, 0.005298806816553326, 0.0989998968076957, 0.011999383624990723, 0.013000624239754364, 0.015999936758080445, 0.19999988077850192, 2.3474497269162665e-7, 0.055002203281556306, 0.15000951511378724 … 0.013000494646773279, 0.015999881032625188, 0.19999918240006212, 0.14222435488284782, 0.004171134748726338, 0.04000004295833059, 0.020000021479165294, 1.0200218592119309e-5, 1.630013359799613, 0.013893165684308173] [0.011999976144766306, 0.0052987447711488715, 0.0989998914699599, 0.01199935121175457, 0.01300065692740689, 0.015999933413613648, 0.199999892086472, 2.347445901835343e-7, 0.05500230202714182, 0.15001057886726488 … 0.01300049926831349, 0.015999841479847905, 0.1999987802590967, 0.1423260605203251, 0.004174856575457383, 0.040000045215210965, 0.020000022607605483, 1.02002396871222e-5, 1.6300155516875665, 0.013881174042431419] [0.011999975256080243, 0.005298695027349113, 0.09899988719198817, 0.011999325198489615, 0.013000683150383342, 0.015999930727570617, 0.19999990241091903, 2.3474427811413793e-7, 0.05500238006078256, 0.15001146776597943 … 0.01300038943116141, 0.01599966796548424, 0.19999674118834446, 0.14240529236314373, 0.004177801169864759, 0.04000004702630021, 0.020000023513150104, 1.0200257639872665e-5, 1.630017475057491, 0.01387115278662455] [0.011999975180955521, 0.005298690810824418, 0.09899988682942772, 0.011999322992389474, 0.013000685373837808, 0.01599993049969667, 0.1999999033366925, 2.3474424995421118e-7, 0.0550023866298144, 0.15001154452870544 … 0.013000322511464891, 0.015999581868992693, 0.19999568929351977, 0.1424113041367429, 0.004178031227750013, 0.04000004717988576, 0.02000002358994288, 1.020025920544025e-5, 1.630017645084667, 0.013870287356322467] ⋮ [0.01118233805821167, 0.004959591522774783, 0.09376096340778832, 0.010780207176371924, 0.012286493623644184, 0.014652301590458437, 0.4069322914192957, 2.2180311552254824e-7, 0.05694898085844847, 0.18173747867746853 … 0.01226311447989848, 0.014620438171265642, 0.4062605758993716, 0.1717315938938936, 0.005930566596823304, 0.049102725254106666, 0.024551362627053333, 9.322806663630839e-6, 1.6431076143984171, 0.014285710557919143] [0.011654254475454442, 0.0052999588873848275, 0.09402331095833467, 0.011162862656318401, 0.012728378992515268, 0.014808033314957553, 0.40494908954500924, 2.277410025130552e-7, 0.05699811530082002, 0.1817679686297123 … 0.01270408640103264, 0.014775752735241994, 0.4042801967590435, 0.17175792000458534, 0.00592944808854608, 0.04911555920218477, 0.024557779601092386, 9.47452598246315e-6, 1.643511978222933, 0.014290905853097793] [0.011894840628712844, 0.0053750928093759575, 0.09446776532266839, 0.011426546293090525, 0.013030559384256622, 0.015061504900917403, 0.4050866430761484, 2.3111767464118986e-7, 0.057033192917395586, 0.1817814030506081 … 0.01300568676073986, 0.015028633322796098, 0.4044168735837665, 0.1717629403710916, 0.005925180582522524, 0.04911997370038709, 0.024559986850193546, 9.611906770452571e-6, 1.6435422391673629, 0.014302393870673736] [0.012084125807943512, 0.0053909284311713535, 0.09554318010690542, 0.011715985065448272, 0.013357413496613233, 0.015614479008587026, 0.4067248723188183, 2.353227101642041e-7, 0.057067877817223875, 0.18180252305727881 … 0.013331901631646123, 0.015580352390030906, 0.4060507695118335, 0.1717611264178342, 0.005912724898781279, 0.04912518571363517, 0.024562592856817583, 9.818871145613538e-6, 1.642827800124465, 0.014334324214928074] [0.012179053233883326, 0.005468814022228754, 0.09609335774477949, 0.011814034688598037, 0.013468279314472021, 0.015797818266012575, 0.40789738960655214, 2.3738217189865025e-7, 0.05707874448732762, 0.181815413488312 … 0.013442510072778557, 0.015763249161175736, 0.407220446185544, 0.17176155426242604, 0.005906210477538862, 0.04913221110450715, 0.024566105552253574, 9.887446215643806e-6, 1.6423144224051243, 0.014351694864998994] [0.012870587308953074, 0.0058621925872992565, 0.09870673309211314, 0.012508952939242179, 0.01426336373692765, 0.016603389944936205, 0.41487169822650427, 2.487352032634948e-7, 0.05716931659283392, 0.18187116437433296 … 0.014235882173411579, 0.01656681233123522, 0.4141788958645611, 0.17175976911972304, 0.005877029377486087, 0.049171681784898315, 0.024585840892449157, 1.027344614233643e-5, 1.6404777885998378, 0.01443154388621727] [0.013240294648726532, 0.00599943500428802, 0.10050412009227239, 0.012932610231149992, 0.014746974354004898, 0.017173724984330254, 0.42068856901267115, 2.551235705450125e-7, 0.05722586413808197, 0.1818991824336602 … 0.014718467043422969, 0.01713573946842206, 0.4199831228219111, 0.1717483253912337, 0.005856860847523665, 0.049194304703463275, 0.024597152351731637, 1.0521989586610765e-5, 1.6391526495838706, 0.014486482653993058] [0.013265120520214987, 0.005905516106443069, 0.10178282250580767, 0.01305110187143539, 0.01487936390528295, 0.017541536504814527, 0.42583768459266175, 2.567808232518947e-7, 0.057237938132301755, 0.1819079777583881 … 0.014850570322927853, 0.01750266104619557, 0.42512151850215074, 0.1717279808952289, 0.005841408967894775, 0.049202902430319474, 0.024601451215159737, 1.063363704388432e-5, 1.6378036141186938, 0.014527436681360214] [0.013157947732736933, 0.005802745679337469, 0.10225384042649276, 0.012990278688044065, 0.014807500356018426, 0.01763017611259584, 0.4282663170245119, 2.5600180320016007e-7, 0.05722644513673933, 0.181907037946052 … 0.014778840498676084, 0.01759108698295746, 0.42754527909159135, 0.17171551610805588, 0.0058350880632722256, 0.04920370896423604, 0.02460185448211802, 1.06332095660501e-5, 1.6370574576910513, 0.014543821816402501]
julia> tSol # the time it took to solve6.83931

Multiple Reactors in Parallel

To model multiple reactors in series, (ie. where the outflow from the first reactor becomes to inflow to the second, and so on) make sure that there are model_parameters.csv files corresponding to each reactor in your working directory. These files should be called model_parameters.csv, model_parameters2.csv, model_parameters3.csv, and so on.

To solve multiple reactors, use the MultiChamberSolution function, which takes the timespan, initial conditions for each reactor, the inflow vector, and the number of reactors as input. The timespan is specified the same as in ADM1sol, the initial conditions are specified as a Tuple of vectors where each vector is the initial conditions for one of the reactors, and the inflow vector is specified the same as in ADM1sol. MultiChamberSolution returns the solutions to reactors as a Tuple, where the first element of the Tuple is the solution to reactor 1, the second is the solution to reactor 2, and so on.

The following code models three reactors in series. Each of the reactors has the same initial conditions.

julia> using ADM1jl
julia> u0 = initialConditions(); # default initial conditions
julia> IV = inflowvector_definition(); # default inflow vector
julia> sols = MultiChamberSolution((0.0,200.0),(u0,u0,u0),IV,3); # solve the three reactorsFinished Chamber 1 Finished Chamber 2 Finished Chamber 3
julia> sols[1] # solution to first reactorretcode: Success Interpolation: specialized 3rd order "free" stiffness-aware interpolation t: 115-element Vector{Float64}: 0.0 1.998068760796162e-5 3.341468554331606e-5 3.988122832624887e-5 4.4680235201568236e-5 4.794627727453984e-5 5.0952331938662506e-5 5.362905748672321e-5 5.577698080992574e-5 5.59591935316201e-5 ⋮ 8.609164585998075 11.792384122076196 17.23534599428072 27.65259736037021 40.9934159708475 60.77931802713721 89.13707315427706 133.678905885535 200.0 u: 115-element Vector{Vector{Float64}}: [0.012, 0.0053, 0.099, 0.012, 0.013, 0.016, 0.2, 2.3e-7, 0.055, 0.15 … 0.013, 0.016, 0.2, 0.14, 0.0041, 0.04, 0.02, 1.02e-5, 1.63, 0.014] [0.011999986305998722, 0.005299528080754454, 0.09899995851630547, 0.011999757994309943, 0.013000244814496508, 0.015999974836690346, 0.19999987668832014, 2.3401029375177689e-7, 0.05500093731160939, 0.15000108782030885 … 0.013000159436964311, 0.015999970507271203, 0.19999977215565246, 0.14093963528890685, 0.004127911003920925, 0.04, 0.02, 1.0200056486177253e-5, 1.6300010043803432, 0.013987846051651676] [0.011999977102201841, 0.005299211849244109, 0.09899993070591713, 0.011999595199349622, 0.013000409099486977, 0.015999957894011495, 0.19999984913764737, 2.3462131401959785e-7, 0.05500151446755541, 0.15000380034967298 … 0.013000313521295812, 0.015999946335854873, 0.19999964945541363, 0.1415212292753339, 0.004146669662439726, 0.04, 0.02, 1.0200111031499442e-5, 1.630003893522008, 0.01395723325778608] [0.01199997267285494, 0.005299059933102669, 0.09899991732837085, 0.011999516807541343, 0.013000488081982675, 0.015999949717195445, 0.19999985166543557, 2.347293069533868e-7, 0.055001776916148076, 0.15000562388554228 … 0.013000386918303651, 0.015999931239462844, 0.19999957058322893, 0.1417877072042461, 0.00415569574693518, 0.04, 0.02, 1.0200145033126272e-5, 1.6300064891566448, 0.013936637777305555] [0.011999969386113186, 0.005298947319276687, 0.09899990740392622, 0.011999458618243508, 0.013000546656182773, 0.015999943639550377, 0.19999986014700516, 2.3474406467471658e-7, 0.055001965283821, 0.1500071824509174 … 0.013000438625344519, 0.015999916159724275, 0.19999947696986942, 0.14197999936663422, 0.0041623915318146935, 0.04, 0.02, 1.0200174359689561e-5, 1.6300090584027846, 0.013919032066060481] [0.011999967149464337, 0.005298870740171685, 0.09899990065057425, 0.011999419010167864, 0.013000586499471117, 0.015999939497968046, 0.19999986913024304, 2.3474522959959367e-7, 0.05500209036090212, 0.15000833975670527 … 0.013000470481880305, 0.015999901501279105, 0.19999936812481842, 0.1421082301384086, 0.004166946010324206, 0.04, 0.02, 1.0200196512193376e-5, 1.630011157417349, 0.013905958298756526] [0.011999965091000644, 0.005298800301401363, 0.09899989443528127, 0.011999382550373399, 0.013000623156476359, 0.015999935682081648, 0.19999987969147337, 2.3474488799855715e-7, 0.055002203256657285, 0.15000947223645938 … 0.013000493702415057, 0.01599988011394127, 0.19999918140535206, 0.14222433850204402, 0.004171134331226857, 0.04, 0.02, 1.0200218587470163e-5, 1.630013359837308, 0.01389316476641871] [0.011999963258166062, 0.005298737615364131, 0.09899988890125047, 0.01199935008118014, 0.01300065578569865, 0.01599993228099467, 0.19999989094073073, 2.347444987540964e-7, 0.05500230199803541, 0.15001053370926534 … 0.01300049826251715, 0.015999840500626243, 0.19999877915797137, 0.14232604017076153, 0.004174856025265061, 0.04, 0.02, 1.0200239681291e-5, 1.6300155516628245, 0.013881173393149072] [0.01199996178749697, 0.005298687337685513, 0.09899988446073249, 0.011999324023898476, 0.01300068196078733, 0.01599992954959562, 0.1999999012174798, 2.3474418112539864e-7, 0.05500238002558099, 0.15001142074354162 … 0.013000388322034054, 0.015999666872248287, 0.19999673918914604, 0.1424052653887559, 0.004177800388075795, 0.04, 0.02, 1.02002576323418e-5, 1.6300174749013072, 0.013871152739877324] [0.011999961662742068, 0.005298683073531872, 0.09899988408404545, 0.011999321813301279, 0.013000684180943878, 0.01599992931779467, 0.1999999021395164, 2.347441524718461e-7, 0.055002386596366144, 0.15001149737441244 … 0.013000321279075213, 0.015999580623548823, 0.19999568545398935, 0.14241127765294348, 0.004178030475579708, 0.04, 0.02, 1.0200259198299479e-5, 1.6300176449752604, 0.013870287064082722] ⋮ [0.011957024281388772, 0.005313145376836529, 0.09946648787238688, 0.011654600434373587, 0.013284591926146994, 0.015582479107210874, 0.19687288370645853, 2.3471110437262594e-7, 0.055090582310417024, 0.15254315137788282 … 0.013254497202185777, 0.015542110712389683, 0.1964857276371254, 0.14264329781345514, 0.004079056450750521, 0.04, 0.02, 1.018738960428329e-5, 1.6256583127128807, 0.014149764848711631] [0.01195654102848209, 0.005313458937485294, 0.09929418665370938, 0.01164865507208881, 0.013277787588848837, 0.015622266425532707, 0.1969233866233376, 2.3495538589926901e-7, 0.05508947273111594, 0.15256470528506616 … 0.01324771163060618, 0.015581799489349265, 0.19653617435469634, 0.14266448807174104, 0.004080233092909001, 0.04, 0.02, 1.0198005071695315e-5, 1.6256250660754588, 0.01415028486767014] [0.011955980109704207, 0.00531386295705003, 0.09907802169827609, 0.011641137972864016, 0.01326918658109571, 0.01567308648104798, 0.19702187144497735, 2.352672348101359e-7, 0.055089337416742594, 0.1525933902838197 … 0.013239136031666108, 0.015632495938305287, 0.1966345420022493, 0.14269314307170092, 0.004082029933356304, 0.04, 0.02, 1.0211565080365322e-5, 1.625621749084325, 0.014150328062007254] [0.011955371939386264, 0.0053143158605383585, 0.09883944038665217, 0.011632771464264816, 0.013259614089760997, 0.015730175804749624, 0.1971596873487173, 2.3561696730430503e-7, 0.05508926775843366, 0.15263045101863412 … 0.013229592968515834, 0.01568944795667104, 0.19677218711874223, 0.14273019624934105, 0.004084370204919226, 0.04, 0.02, 1.0226772178030066e-5, 1.625620443499663, 0.01415033918241631] [0.011955036272014314, 0.0053145727297110815, 0.0987062051950052, 0.011628053850075558, 0.013254216446260576, 0.015762608072920514, 0.1972650063546642, 2.358156012903638e-7, 0.05508923137310232, 0.15265675340982643 … 0.01322421304832514, 0.015721803754039324, 0.19687737030075056, 0.14275649532397347, 0.004086034426312779, 0.04, 0.02, 1.0235409193646683e-5, 1.6256197935003422, 0.014150344102072282] [0.011954879037458292, 0.005314697865111298, 0.09864241740321439, 0.011625770979812398, 0.01325160448275435, 0.01577837229712297, 0.197339362116905, 2.3591236791138904e-7, 0.05508921431514828, 0.1526741080818041 … 0.013221610629336295, 0.015737532123255283, 0.19695162694908167, 0.1427738486162467, 0.004087134222202541, 0.04, 0.02, 1.0239616823376926e-5, 1.6256194976733636, 0.014150346161797715] [0.011954836213455822, 0.00531473416356305, 0.09862432560165917, 0.011625114587568658, 0.013250853454556363, 0.01578291681184238, 0.19737459437098553, 2.3594040068890368e-7, 0.05508920948740529, 0.15268186309600545 … 0.013220862924643861, 0.01574206708874299, 0.19698681099245025, 0.14278160328937375, 0.0040876262817559055, 0.04, 0.02, 1.024083576246797e-5, 1.6256194164919724, 0.014150346675181056] [0.011954830158706282, 0.0053147398286552405, 0.09862158138802907, 0.01162501321766733, 0.013250737466870395, 0.015783619896173714, 0.1973850412510544, 2.3594476937421984e-7, 0.05508920874769569, 0.15268406799526774 … 0.013220747661280148, 0.015742768982620215, 0.1969972433244719, 0.14278380814515448, 0.004087766294494727, 0.04, 0.02, 1.0241025727130154e-5, 1.6256194045086088, 0.014150346741486993] [0.011954829810563401, 0.0053147401832121036, 0.09862141249882697, 0.011625006887037806, 0.013250730223207484, 0.015783663823179507, 0.19738633671962316, 2.3594504387169125e-7, 0.05508920869990237, 0.15268433594303998 … 0.013220740490142689, 0.015742812872396397, 0.1969985369743189, 0.1427840760901829, 0.004087783314163287, 0.04, 0.02, 1.0241037663368444e-5, 1.6256194037384155, 0.014150346745679485]
julia> sols[2] # solution to second reactorretcode: Success Interpolation: specialized 3rd order "free" stiffness-aware interpolation t: 217-element Vector{Float64}: 0.0 1.9851374981602857e-5 3.2682986451519587e-5 3.847591896164129e-5 4.3104491595261513e-5 4.6287510143157195e-5 4.927015887067483e-5 5.197811676347514e-5 5.412698033670444e-5 5.4754167899967724e-5 ⋮ 29.19129527135732 38.20046287249894 47.20963047364056 61.13201182611274 75.05439317858492 95.91681663354653 124.06179203431535 162.88561632942 200.0 u: 217-element Vector{Vector{Float64}}: [0.012, 0.0053, 0.099, 0.012, 0.013, 0.016, 0.2, 2.3e-7, 0.055, 0.15 … 0.013, 0.016, 0.2, 0.14, 0.0041, 0.04, 0.02, 1.02e-5, 1.63, 0.014] [0.011998656984719339, 0.005298483375366199, 0.09900031530065502, 0.0119993843522271, 0.012999851800565234, 0.015999868758668455, 0.19999990198144257, 2.6957950128369177e-7, 0.05501376765683235, 0.15000523182263475 … 0.012999888522301273, 0.015999903160126797, 0.199999885098036, 0.1409680180778049, 0.004124488017183085, 0.04, 0.02, 1.0202786595471042e-5, 1.6299963234939079, 0.013943552256647871] [0.011997788811392933, 0.005297504341496606, 0.09900051934149404, 0.011998986346232211, 0.012999755709573622, 0.015999784447447127, 0.1999998822933996, 2.757376343408087e-7, 0.055022611440206114, 0.1500104498439126 … 0.01299979072721641, 0.0159998156107829, 0.19999979738629886, 0.14154353618838822, 0.004140310957143747, 0.04, 0.02, 1.0204644441775828e-5, 1.6299996803497347, 0.013886089247368717] [0.011997396849762487, 0.005297062679620153, 0.09900061137558341, 0.011998806592611527, 0.012999712187956309, 0.015999746368582608, 0.1999998848255819, 2.768570863864637e-7, 0.05502658703692871, 0.1500132344054407 … 0.012999743886651495, 0.0159997729003579, 0.19999974437886195, 0.1417912681578572, 0.004147451792415806, 0.04, 0.02, 1.0205497098017696e-5, 1.630003139689085, 0.01385525402944573] [0.011997083663092326, 0.005296709937940829, 0.09900068487551875, 0.0119986629379216, 0.012999677351984018, 0.01599971593676725, 0.1999998919332661, 2.7697723935134527e-7, 0.05502975605780108, 0.15001563992764846 … 0.012999704178467367, 0.015999735808753034, 0.19999967814045908, 0.14198399014860466, 0.004153155224763667, 0.04, 0.02, 1.0206185414505598e-5, 1.6300068890524797, 0.013828556795135572] [0.01199686828393607, 0.005296467437420529, 0.09900073539004357, 0.011998564126505443, 0.012999653357005144, 0.01599969499498458, 0.19999989945782043, 2.7698472906165636e-7, 0.05503193122809367, 0.15001738407019122 … 0.012999674280370016, 0.015999706896129937, 0.19999960058992566, 0.14211387030227432, 0.004157075424456794, 0.04, 0.02, 1.0206662048179203e-5, 1.6300100085919125, 0.01380917292127657] [0.011996666459767467, 0.005296240258435669, 0.09900078270033759, 0.011998471518393897, 0.012999630842957272, 0.015999675359475662, 0.19999990845759857, 2.7698257053417846e-7, 0.055033966391131096, 0.15001908303259995 … 0.01299964142465624, 0.015999673453156903, 0.1999994639706716, 0.14223360122934517, 0.004160745807632211, 0.04, 0.02, 1.0207111147785336e-5, 1.630013350839862, 0.013790273127684357] [0.011996483220298433, 0.0052960340488759985, 0.09900082563284573, 0.011998387424913904, 0.01299961037747024, 0.015999657522028064, 0.19999991825783664, 2.7698013847853985e-7, 0.05503581154719929, 0.15002067836151053 … 0.012999597758824179, 0.015999625083255337, 0.19999915120828576, 0.14234053922704534, 0.004164071138548151, 0.04, 0.02, 1.0207521023779131e-5, 1.6300167490660888, 0.01377251217185427] [0.011996337811352125, 0.005295870445929593, 0.0990008596873408, 0.011998320684023414, 0.012999594120492926, 0.01599964336037904, 0.19999992708509243, 2.76978187382676e-7, 0.05503727405614543, 0.15002197923671445 … 0.01299943476926749, 0.015999423342630305, 0.19999711680141832, 0.14242291424848796, 0.004166663124203151, 0.04, 0.02, 1.0207847768477014e-5, 1.6300196994321494, 0.013758020559343671] [0.011996295077211583, 0.00529582189710922, 0.0990008692272602, 0.011998301096751932, 0.012999589273747666, 0.015999639086815554, 0.2000001549422336, 2.695230843808437e-7, 0.055037496943385555, 0.15002236546703138 … 0.013016208581867049, 0.01602064743633841, 0.20023147260352117, 0.1426222409601087, 0.004173069857782228, 0.04, 0.02, 1.0207935170391165e-5, 1.6300206035195643, 0.013753677040700745] ⋮ [0.0006810180791458052, 0.0001329479159993573, 0.007790838992497644, 0.00030328752030228055, 0.00037300796441946536, 0.0005420251775377093, 0.012316319120131428, 1.3785481874005095e-8, 0.053593632273477465, 0.1596102061928806 … 0.0003722737109942578, 0.0005408035244500878, 0.01229521162435139, 0.1500859049627662, 0.0035668745227487786, 0.04, 0.02, 7.272280498944575e-7, 1.6719490514745405, 0.012407073913573178] [0.0006838084042277719, 0.00013393690187805805, 0.00782687462790541, 0.0003058071019483005, 0.0003759273133716299, 0.0005472043064172905, 0.012504619202225621, 1.3872164077012232e-8, 0.053458737293029635, 0.1598943568561667 … 0.0003751845944637782, 0.0005459664729106447, 0.012483110662736987, 0.15032068268184728, 0.003560514229309849, 0.04, 0.02, 7.317756719910073e-7, 1.6677944030940108, 0.012471410980143996] [0.0006852805925779481, 0.000134445847763594, 0.007846165580428915, 0.00030707333570184175, 0.0003773890256329715, 0.0005500333517962018, 0.012583259059675864, 1.3922306075616645e-8, 0.05341610575421317, 0.1600333018562694 … 0.000376642823052922, 0.0005487881233748732, 0.012561598130813714, 0.15044432749503825, 0.0035611598448971517, 0.04, 0.02, 7.344012627112337e-7, 1.6664964670080358, 0.012491353486378453] [0.0006862919718537996, 0.0001347869785635931, 0.007856051467976622, 0.0003078667952472284, 0.0003783009148931726, 0.0005522628534657401, 0.012625676378017358, 1.3959979564304538e-8, 0.05340352905060519, 0.16012959901385776 … 0.00037755302768925576, 0.000551012776837241, 0.012603946017679503, 0.15053640843640334, 0.003564301938944368, 0.04, 0.02, 7.36378936330561e-7, 1.6661283454822138, 0.01249685406231584] [0.0006866557121379953, 0.0001349057216762273, 0.007859059683180894, 0.0003081232172546985, 0.0003785932640578422, 0.000553159417316042, 0.012637066229521005, 1.3975504878886445e-8, 0.05340430688458381, 0.16016776592102216 … 0.0003778450259376653, 0.0005519076888332627, 0.012615322904252673, 0.1505750561872446, 0.0035664547414078324, 0.04, 0.02, 7.371930276364072e-7, 1.666162054607024, 0.012496230762377117] [0.000686813600183649, 0.00013495582077517983, 0.0078597651464674, 0.00030821749887806576, 0.0003786990914625513, 0.000553625477041756, 0.01264028319066397, 1.3983563405555136e-8, 0.05340648519488808, 0.16019031990488744 … 0.00037795083087688124, 0.0005523730033184602, 0.01261853976108064, 0.15059851508859504, 0.003567988273772339, 0.04, 0.02, 7.376144144818649e-7, 1.6662345014634716, 0.012495053369363528] [0.0006868510255852962, 0.00013496713103064607, 0.007859777195739426, 0.0003082352900046195, 0.00037871862927053114, 0.0005537536491610954, 0.012640821552767358, 1.3985734757574242e-8, 0.053407375010505374, 0.16019853226624547 … 0.00037797040026859793, 0.0005525010022040886, 0.012619079239612776, 0.15060708154471458, 0.0035685569120923587, 0.04, 0.02, 7.377280630168422e-7, 1.6662633192073357, 0.012494592430499878] [0.0006868561496940145, 0.0001349685890158989, 0.007859774700793852, 0.00030823713753158226, 0.000378720570058208, 0.0005537733729952742, 0.012640806577121595, 1.3986086990463698e-8, 0.053407519970157614, 0.16020060930568494 … 0.0003779723523448188, 0.0005525207065405124, 0.012619064728518871, 0.1506092160804738, 0.003568687112199, 0.04, 0.02, 7.377464596367945e-7, 1.6662680048893062, 0.012494517581547876] [0.0006868564894131577, 0.0001349686914146657, 0.007859763626337144, 0.0003082370911850209, 0.0003787204935946207, 0.000553775927587343, 0.012640796815728866, 1.3986123730579595e-8, 0.05340754020762896, 0.160201065807556 … 0.00037797227894472606, 0.0005525232602146877, 0.012619055068761056, 0.15060968024054538, 0.0035687136187715443, 0.04, 0.02, 7.37748384328485e-7, 1.6662686404274447, 0.012494507606915678]
julia> sols[3] # solution to third reactorretcode: Success Interpolation: specialized 3rd order "free" stiffness-aware interpolation t: 178-element Vector{Float64}: 0.0 1.9851374981612845e-5 3.2682986451536026e-5 3.847592020475051e-5 4.310449481237983e-5 4.6287747136929004e-5 4.927350641631825e-5 5.20367176136299e-5 5.4153358809119746e-5 5.4683521584569634e-5 ⋮ 71.75349242050822 73.7729039711974 85.67235501096259 92.45998351879426 109.29065068631796 126.63837477749274 138.826964561422 178.71642270229856 200.0 u: 178-element Vector{Vector{Float64}}: [0.012, 0.0053, 0.099, 0.012, 0.013, 0.016, 0.2, 2.3e-7, 0.055, 0.15 … 0.013, 0.016, 0.2, 0.14, 0.0041, 0.04, 0.02, 1.02e-5, 1.63, 0.014] [0.011998656983821555, 0.005298483374660787, 0.0990003153008966, 0.011999384351975052, 0.01299985180030014, 0.01599986875859748, 0.1999999019814556, 2.695795030124549e-7, 0.05501376766551008, 0.15000523182542574 … 0.01299988852207385, 0.015999903160068243, 0.1999998850980766, 0.1409680180965331, 0.0041244880148715935, 0.04, 0.02, 1.0202786597359412e-5, 1.629996323491996, 0.013943552226828398] [0.011997788809139988, 0.005297504339732127, 0.0990005193421002, 0.011998986345602088, 0.012999755708905157, 0.015999784447269204, 0.19999988229342258, 2.757376361562104e-7, 0.055022611461949096, 0.150010449850815 … 0.012999790726589468, 0.01599981561061926, 0.19999979738635754, 0.1415435362238592, 0.004140310951027315, 0.04, 0.02, 1.0204644446538715e-5, 1.6299996803494892, 0.013886089173638858] [0.011997396846619848, 0.005297062677110312, 0.09900061137642367, 0.011998806591706908, 0.012999712187050027, 0.01599974636833176, 0.1999998848256088, 2.7685708814323547e-7, 0.05502658706731143, 0.1500132344156532 … 0.01299974388578543, 0.015999772900119016, 0.19999974437889767, 0.14179126829291294, 0.004147451786862763, 0.04, 0.02, 1.0205497104685231e-5, 1.630003139692862, 0.013855253919932465] [0.011997083659081796, 0.005296709934698617, 0.09900068487658661, 0.011998662936746255, 0.012999677350848572, 0.015999715936444912, 0.19999989193329953, 2.7697724111118904e-7, 0.05502975609660773, 0.15001563994129802 … 0.012999704177367557, 0.015999735808436163, 0.1999996781404335, 0.1419839903857225, 0.004153155220092452, 0.04, 0.02, 1.0206185423040746e-5, 1.6300068890620127, 0.013828556648320955] [0.011996868263555694, 0.005296467415935087, 0.0990007353949679, 0.011998564117915821, 0.012999653353944363, 0.015999694993079835, 0.19999989945848762, 2.7698473058818067e-7, 0.05503193143183328, 0.15001738421637748 … 0.012999674276769766, 0.0159997068934579, 0.1999996005823504, 0.14211388001010616, 0.004157075706343152, 0.04, 0.02, 1.020666209300467e-5, 1.6300100088510818, 0.013809171301403068] [0.011996666228354267, 0.005296239999628036, 0.09900078275473445, 0.011998471413059332, 0.01299963081623653, 0.01599967533704241, 0.1999999084687832, 2.7698256924523937e-7, 0.055033968720824195, 0.15001908498930228 … 0.012999641381272466, 0.015999673408560473, 0.1999994637483745, 0.14223373463754163, 0.004160749912907059, 0.04, 0.02, 1.020711166362121e-5, 1.6300133548381304, 0.013790251357896684] [0.011996479249488835, 0.005296029582656952, 0.09900082656315447, 0.011998385603421546, 0.012999609932733804, 0.01599965713548121, 0.199999918487036, 2.7698008699592925e-7, 0.05503585150222965, 0.15002071344822573 … 0.012999596399401613, 0.015999623502398554, 0.19999913874943145, 0.14234283171192097, 0.00416414290259959, 0.04, 0.02, 1.0207529928183038e-5, 1.6300168265337158, 0.013772121416253159] [0.011996336020497496, 0.005295868433159254, 0.09900086010687423, 0.011998319863028139, 0.012999593919111568, 0.015999643186032482, 0.1999999268579038, 2.769781651677279e-7, 0.05503729237830032, 0.15002199548055267 … 0.012999455188702649, 0.015999449714769565, 0.19999740254287396, 0.14242419496264588, 0.004166703829566656, 0.04, 0.02, 1.0207851800355833e-5, 1.6300197370951417, 0.01375783960372] [0.011996300048255616, 0.0052958278083538035, 0.09900086833860042, 0.011998303343052937, 0.012999589852801667, 0.01599963961289579, 0.20000067015203535, 2.7212499154662237e-7, 0.055036959591183106, 0.1500222992209195 … 0.012991671232879936, 0.01598950891944664, 0.19988927629509154, 0.1423562789146483, 0.004164499059361989, 0.04, 0.02, 1.0207928222481502e-5, 1.6300205000647756, 0.013754335134724302] ⋮ [0.0005135462531424544, 8.067626650625642e-5, 0.004896378914370214, 0.00016407718234969393, 0.00021349632088581226, 0.0003190708776848575, 0.006260464828157652, 8.566401837654952e-9, 0.051586426118123106, 0.1635051205258127 … 0.00021305475521521215, 0.00031831618244037213, 0.006249225835599648, 0.15333711760960747, 0.003495956871013299, 0.04, 0.02, 4.470301997235443e-7, 1.6146647175314082, 0.01324733448424171] [0.0005135613071163213, 8.068087308137812e-5, 0.004896100494895547, 0.00016408014513106975, 0.00021349975968134295, 0.0003191495422282159, 0.0062611975257256675, 8.5674071260678e-9, 0.05158368138294057, 0.16352225460696868 … 0.00021305819302976488, 0.0003183946713280551, 0.006249957374385242, 0.15335331804740515, 0.0034964298563115222, 0.04, 0.02, 4.4708506597057255e-7, 1.614583554759322, 0.013248552580635264] [0.0005136196548294819, 8.069552941181216e-5, 0.0048948334204521275, 0.0001640795937714737, 0.00021349757492903634, 0.00031946046594721986, 0.0062625622468237135, 8.571730964719469e-9, 0.05157707785861392, 0.16358644047737914 … 0.00021305609958386976, 0.0003187050080569664, 0.00625132185627014, 0.1534153902526562, 0.003498745237149742, 0.04, 0.02, 4.4731924176353547e-7, 1.614394810676778, 0.013251312759823303] [0.0005136393037896427, 8.069924062027777e-5, 0.004894117345255983, 0.00016407050092026717, 0.00021348528505210501, 0.0003195973038948755, 0.006262127333459481, 8.573798812255783e-9, 0.05157731210346888, 0.163610240160962 … 0.00021304391331898945, 0.00031884165620279294, 0.0062508897155753446, 0.15343940325515693, 0.003499995401378326, 0.04, 0.02, 4.474299800115635e-7, 1.6144083151498398, 0.013251037012604366] [0.0005136618945491196, 8.070166827749186e-5, 0.004893331143209296, 0.00016405500851543592, 0.00021346463316702387, 0.0003197492738129642, 0.006261110856340687, 8.576333168499813e-9, 0.05157938120489233, 0.16363717191804358 … 0.00021302342370434083, 0.00031899347153756057, 0.006249878108185945, 0.153467250603663, 0.003501675388942479, 0.04, 0.02, 4.4756533381333315e-7, 1.6144799230005706, 0.01324984652985369] [0.0005136703132119752, 8.070174464012045e-5, 0.004892879425412746, 0.00016404386133969155, 0.00021344992377908496, 0.0003198269736990599, 0.006260244774111566, 8.577690762817904e-9, 0.05158142450289386, 0.16365078145041165 … 0.0002130088216244714, 0.0003190711195464954, 0.0062490155382607, 0.15348168044556548, 0.0035026652853575742, 0.04, 0.02, 4.476374372207031e-7, 1.6145465093964406, 0.013248778700348858] [0.000513672297188565, 8.070157398543158e-5, 0.0048927760619710495, 0.0001640406637893434, 0.00021344571936787577, 0.0003198450968086689, 0.006259979917162632, 8.578035415610227e-9, 0.05158208941641052, 0.16365436368276745 … 0.0002130046482927659, 0.00031908923812604606, 0.006248751726902801, 0.15348552479278135, 0.0035029438663220476, 0.04, 0.02, 4.47655709328636e-7, 1.6145679400514519, 0.013248437416539405] [0.0005136737779626896, 8.07012661235866e-5, 0.0048926684626265085, 0.00016403716424777092, 0.00021344112974768775, 0.00031986303337172816, 0.006259667161971579, 8.578382315100148e-9, 0.05158278990500614, 0.16365884460326652 … 0.00021300009361129222, 0.0003191071759128256, 0.006248440180931736, 0.15349027876816887, 0.0035032709850552884, 0.04, 0.02, 4.476740458508581e-7, 1.614590365557346, 0.013248081837233047] [0.0005136738789980777, 8.070123612407503e-5, 0.004892651306127082, 0.00016403672081640767, 0.00021344054960827105, 0.00031986553438415977, 0.006259623206315586, 8.57842587095608e-9, 0.05158286141183762, 0.16365963128035452 … 0.00021299951820920508, 0.00031910967707393206, 0.006248396394254673, 0.1534910931982967, 0.0035033204624585444, 0.04, 0.02, 4.476763402733697e-7, 1.6145926488198286, 0.013248045694506628]

Variable Inflow

To specify variable inflow to the first reactor in the series, the input is much the same as in the ADM1sol case:

julia> using ADM1jl
julia> u0 = initialConditions();
julia> t = [i for i in 0.0:0.1:50.0];
julia> IV_temp = inflowvector_definition();
julia> IV = [IV_temp*(0.5*rand()+1.0) for i in 1:length(t)];
julia> sols = MultiChamberSolution((0.0,50.0),(u0,u0,u0),IV,t,3);Finished Chamber 1 Finished Chamber 2 Finished Chamber 3

Plotting

ADM1jl has a built-in plotting function, plotSols, that uses Julia's Plots package to plot the solutions. The following code demonstrates how it functions:

julia> using ADM1jl
julia> u0 = initialConditions(); # assigns the default initial conditions to u0
julia> IV = inflowvector_definition(); # assigns the default inflow vector to IV
julia> tspan = (0.0,200.0); # the solution will be computed from t=0.0 to t=200.0
julia> sol, tSol = ADM1sol(tspan,u0,IV); # compute the solution
julia> plotSols(sol) # displays the plots

However, there is an error in the Plots package that may cause the plots to overwrite eachother so that only the second plot is displayed. To work around this the following keyword arguments can be used:

julia> using ADM1jl
julia> u0 = initialConditions();
julia> IV = inflowvector_definition();
julia> sol, tSol = ADM1sol((0.0,200.0),u0,IV); # compute the solution
julia> plt1,plt2 = plotSols(sol,displayPlots=false,returnPlots=true); # stop the plots from displaying automatically and return the plots objects instead
julia> display(plt1) # display the first plot manually
julia> display(plt2) # display the second plot manually

To change the title of the plots use the titleText keyword argument. To save the plots as .png files, use the savePNG boolean keyword argument. The files will have the same name as the plots titles. For example, the following code titles the plots "Sample Plots" and saves them as Sample Plots (1 of 2).png and Sample Plots (2 of 2).png.

julia> using ADM1jl
julia> u0 = initialConditions();
julia> IV = inflowvector_definition();
julia> sol, tSol = ADM1sol((0.0,200.0),u0,IV); # compute the solution
julia> plotSols(sol,titleText="Sample Plots",displayPlots=false,savePNG=true); # title the plots "Sample Plots" and save them to .png files

State Variables and their Indices

The follow table shows which state variable corresponds to each index.

IndexState Variable
1S_su
2S_aa
3S_fa
4S_va
5S_bu
6S_pr
7S_ac
8S_h2
9S_ch4
10S_IC
11S_IN
12S_I
13X_xc
14X_ch
15X_pr
16X_li
17X_su
18X_aa
19X_fa
20X_c4
21X_pro
22X_ac
23X_h2
24X_I
25S_va_ion
26S_bu_ion
27S_pro_ion
28S_ac_ion
29S_hco3_ion
30S_nh3
31S_cat
32S_an
33S_gas_h2
34S_gas_ch4
35S_gas_co2