Skip to content

Commit 10f7cdc

Browse files
committed
Test new interface jacobian
Use list not tuple
1 parent cf4e1d8 commit 10f7cdc

File tree

1 file changed

+24
-0
lines changed

1 file changed

+24
-0
lines changed

src/TestReactors.jl

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,30 @@ jp=jacobianpforwarddiff(y,p,t,domain,[],nothing);
3535
@test all((abs.(jpa.-jp) .> 1e-4.*abs.(jp).+1e-16).==false)
3636
end;
3737

38+
@testset "Test liquid phase Constant T Constant V reactor with volumetric flow rate inlet and outlet simulation" begin
39+
#Constant T and V Ideal Dilute Liquid
40+
initialconds = Dict(["T"=>450.0,"V"=>1.0e-6*1e6,"octane"=>6.154e-3*1e6,"oxygen"=>4.953e-6*1e6]) #Set simulation Initial Temp and Pressure
41+
domain,y0,p = ConstantTVDomain(phase=liq,initialconds=initialconds) #Define the domain (encodes how system thermodynamic properties calculated)
42+
43+
inlet = VolumetricFlowRateInlet(domain,Dict(["T"=>450.0,"P"=>1.e5,"octane"=>6.154e-3*1e6,"oxygen"=>4.953e-6*1e6]),x->1.0) #set the inlet flow rate and conditions
44+
outlet = VolumetricFlowRateOutlet(domain,x->1.0) #set the outlet flow rate
45+
interfaces = [inlet,outlet]
46+
react = Reactor(domain,y0,(0.0,140000.01),interfaces;p=p) #Create the reactor object
47+
48+
sol = solve(react.ode,CVODE_BDF(),abstol=1e-20,reltol=1e-8); #solve the ode associated with the reactor
49+
50+
#analytic jacobian vs. ForwardDiff jacobian
51+
t=32977.61568;
52+
y=sol(t)
53+
ja=jacobiany(y,p,t,domain,[],nothing);
54+
j=jacobianyforwarddiff(y,p,t,domain,[],nothing);
55+
@test all((abs.(ja.-j) .> 1e-4.*abs.(j).+1e-16).==false)
56+
57+
jpa=jacobianp(y,p,t,domain,[],nothing);
58+
jp=jacobianpforwarddiff(y,p,t,domain,[],nothing);
59+
@test all((abs.(jpa.-jp) .> 1e-4.*abs.(jp).+1e-16).==false)
60+
end;
61+
3862
@testset "Test liquid phase Constant T Constant V reactor simulation with kLAkHCondensationEvaporationWithReservoir" begin
3963
phaseDict = readinput("../src/testing/constantkLAkH.rms")
4064

0 commit comments

Comments
 (0)