@@ -2092,9 +2092,13 @@ end
2092
2092
# -= d/dni(dni/dt)*R*T/P
2093
2093
# d/dV(dV/dt) -= sum(d/dV(dn/dt))*R*T/P
2094
2094
@simd for i in domain. indexes[1 ]: domain. indexes[2 ]
2095
- @inbounds @fastmath jac[i,i] -= kLAs[i]/ kHs[i]
2095
+ ddnidnidt = kLAs[i]* inter. V/ V* R* T/ kHs[i]
2096
+ @inbounds @fastmath jac[i,i] -= ddnidnidt
2097
+ @inbounds @fastmath jac[domain. indexes[3 ],i] -= ddnidnidt* R* T/ P
2096
2098
end
2097
- @views @inbounds @fastmath jac[domain. indexes[1 ]: domain. indexes[2 ],domain. indexes[3 ]] .- = kLAs./ kHs* R* T/ P
2099
+ ddVdndt = kLAs.* inter. V.* cs* (- 1 / V)* R* T./ kHs
2100
+ @views @inbounds @fastmath jac[domain. indexes[1 ]: domain. indexes[2 ],domain. indexes[3 ]] .- = ddVdndt
2101
+ @views @inbounds @fastmath jac[domain. indexes[3 ],domain. indexes[3 ]] -= sum (ddVdndt)* R* T/ P
2098
2102
elseif isa (inter,VolumetricFlowRateInlet) && domain == inter. domain
2099
2103
# dn/dt += inter.Vin(t)*inter.cs
2100
2104
# dV/dt += inter.Vin(t)
@@ -2226,11 +2230,12 @@ end
2226
2230
flow = sum (cond)
2227
2231
@fastmath dTdt = (P* V/ N* flow)/ (N* Cvave)
2228
2232
@simd for i in domain. indexes[1 ]: domain. indexes[2 ]
2229
- @inbounds @fastmath jac[i,i] -= kLAs[i]/ kHs[i]
2233
+ ddnidnidt = kLAs[i]* inter. V/ V* R* T/ kHs[i]
2234
+ @inbounds @fastmath jac[i,i] -= ddnidnidt
2230
2235
@inbounds @fastmath dCvavedni = cpdivR[i]* R/ N
2231
- @fastmath ddnidTdt = (P* V/ N* kLAs[i] / kHs[i] )/ (N* Cvave)- dTdt* (dCvavedni/ Cvave)
2236
+ @fastmath ddnidTdt = (P* V/ N* ddnidnidt )/ (N* Cvave) - dTdt* (dCvavedni/ Cvave)
2232
2237
@inbounds jac[domain. indexes[3 ],i] -= ddnidTdt
2233
- @inbounds @fastmath jac[domain. indexes[4 ],i] -= kLAs[i] / kHs[i] * R* T/ V + P/ T* ddnidTdt
2238
+ @inbounds @fastmath jac[domain. indexes[4 ],i] -= ddnidnidt * R* T/ V + P/ T* ddnidTdt
2234
2239
end
2235
2240
elseif isa (inter,VolumetricFlowRateInlet) && domain == inter. domain
2236
2241
# dn/dt += inter.Vin(t)*inter.cs
@@ -2398,8 +2403,7 @@ end
2398
2403
end
2399
2404
@fastmath ddVdTdt = flow* H/ V/ (N* Cpave)
2400
2405
@inbounds jac[domain. indexes[3 ],domain. indexes[4 ]] += ddVdTdt
2401
- @inbounds @fastmath jac[domain. indexes[1 ]: domain. indexes[2 ],domain. indexes[4 ]] .+ = kLAs.* inter. cs
2402
- @inbounds @fastmath jac[domain. indexes[4 ],domain. indexes[4 ]] += flow/ N + dTdt/ T + V/ T* ddVdTdt
2406
+ @inbounds @fastmath jac[domain. indexes[4 ],domain. indexes[4 ]] += dTdt/ T + V/ T* ddVdTdt
2403
2407
2404
2408
# condensation
2405
2409
# dn/dt .-= kLAs.*inter.V.*cs*R*T./kHs
@@ -2413,9 +2417,13 @@ end
2413
2417
# -= ddnidnidt*R*T/P
2414
2418
# d/dV(dV/dt) -= sum(d/dV(dn/dt))*R*T/P
2415
2419
@simd for i in domain. indexes[1 ]: domain. indexes[2 ]
2416
- @inbounds @fastmath jac[i,i] -= kLAs[i]/ kHs[i]
2420
+ ddnidnidt = kLAs[i]* inter. V/ V* R* T/ kHs[i]
2421
+ @inbounds @fastmath jac[i,i] -= ddnidnidt
2422
+ @inbounds @fastmath jac[domain. indexes[4 ],i] -= ddnidnidt* R* T/ P
2417
2423
end
2418
- @views @inbounds @fastmath jac[domain. indexes[4 ],domain. indexes[1 ]: domain. indexes[2 ]] .- = kLAs./ kHs* R* T/ P
2424
+ ddVdndt = kLAs.* inter. V.* cs* (- 1 / V)* R* T./ kHs
2425
+ @views @inbounds @fastmath jac[domain. indexes[1 ]: domain. indexes[2 ],domain. indexes[4 ]] .- = ddVdndt
2426
+ @views @inbounds @fastmath jac[domain. indexes[4 ],domain. indexes[4 ]] .- = sum (ddVdndt)* R* T/ P
2419
2427
elseif isa (inter,VolumetricFlowRateInlet) && domain == inter. domain
2420
2428
# dn/dt .+= inter.Vin(t)*inter.cs
2421
2429
# dT/dt += inter.Vin(t)*(inter.Hpervolume - dot(Hs,ns)/V)/(N*Cpave)
@@ -2501,12 +2509,12 @@ end
2501
2509
kHs = map .(inter. kHs,inter. T)
2502
2510
2503
2511
# evaporaiton
2504
- # inlet
2505
- # d/dV (dni /dt) = dflow_i/dV = - kLAs[i] *inter.cs[i]/V^2
2506
- # flow = sum(kLAs.*inter.cs)/V
2507
- # flow_i = kLAs[i]*inter.cs[i]/V
2508
- # dflow_idV = -kLAs[i]*inter.cs[i]/V^2
2509
- @views @inbounds @fastmath jac[domain . indexes[ 1 ] : domain . indexes[ 2 ],domain . indexes[ 3 ]] . += - kLAs .* inter . cs / (V * V)
2512
+ # dn/dt .+= kLAs.*inter.V.*inter.cs
2513
+ # dV /dt += sum( kLAs. *inter.V.*inter.cs)*R*T/P
2514
+ # d/dni(dni/dt) += 0
2515
+ # d/dV(dni/dt) += 0
2516
+ # d/dni(dV/dt) += 0
2517
+ # d/dV(dV/dt) += 0
2510
2518
2511
2519
# condensation
2512
2520
# dn/dt .-= kLAs.*inter.V.*cs*R*T./kHs
@@ -2517,9 +2525,13 @@ end
2517
2525
# -= d/dni(dni/dt)*R*T/P
2518
2526
# d/dV(dV/dt) -= sum(d/dV(dn/dt))*R*T/P
2519
2527
@simd for i in domain. indexes[1 ]: domain. indexes[2 ]
2520
- @inbounds @fastmath jac[i,i] -= kLAs[i]/ kHs[i]
2528
+ ddnidnidt = kLAs[i]* inter. V/ V* R* T/ kHs[i]
2529
+ @inbounds @fastmath jac[i,i] -= ddnidnidt
2530
+ @inbounds @fastmath jac[domain. indexes[3 ],i] -= ddnidnidt* R* T/ P
2521
2531
end
2522
- @views @inbounds @fastmath jac[domain. indexes[3 ],domain. indexs[1 ]: domain. indexes[2 ]] .- = kLAs./ kHs* R* T/ P
2532
+ ddVdndt = kLAs.* inter. V.* cs.* (- 1 / V)* R* T./ kHs
2533
+ @views @inbounds @fastmath jac[domain. indexs[1 ]: domain. indexes[2 ],domain. indexes[3 ]] .- = ddVdndt
2534
+ @views @inbounds @fastmath jac[domain. indexes[3 ],domain. indexes[3 ]] -= sum (ddVdndt)* R* T/ P
2523
2535
elseif isa (inter,VolumetricFlowRateInlet) && domain == inter. domain
2524
2536
# dn/dt .+= inter.Vin(t)*inter.cs
2525
2537
# dV/dt += inter.Vin(t)
@@ -2638,11 +2650,12 @@ end
2638
2650
flow = sum (cond)
2639
2651
@fastmath dTdt = (P* V/ N* flow)/ (N* Cvave)
2640
2652
@simd for i in domain. indexes[1 ]: domain. indexes[2 ]
2641
- @inbounds @fastmath jac[i,i] -= kLAs[i]/ kHs[i]
2653
+ ddnidnidt = kLAs[i]* inter. V/ V* R* T/ kHs[i]
2654
+ @inbounds @fastmath jac[i,i] -= ddnidnidt
2642
2655
@inbounds @fastmath dCvavedni = cpdivR[i]* R/ N
2643
- @fastmath ddnidTdt = (P* V/ N* kLAs[i] / kHs[i] )/ (N* Cvave)- dTdt* (dCvavedni/ Cvave)
2656
+ @fastmath ddnidTdt = (P* V/ N* ddnidnidt )/ (N* Cvave) - dTdt* (dCvavedni/ Cvave)
2644
2657
@inbounds jac[domain. indexes[3 ],i] -= ddnidTdt
2645
- @inbounds @fastmath jac[domain. indexes[4 ],i] -= kLAs[i] / kHs[i] * R* T/ V + P/ T* ddnidTdt
2658
+ @inbounds @fastmath jac[domain. indexes[4 ],i] -= ddnidnidt * R* T/ V + P/ T* ddnidTdt
2646
2659
end
2647
2660
elseif isa (inter,VolumetricFlowRateInlet) && domain == inter. domain
2648
2661
# dn/dt .+= inter.Vin(t)*inter.cs
@@ -2793,14 +2806,13 @@ end
2793
2806
@fastmath dTdt = flow* (inter. H - H)/ (N* Cpave)
2794
2807
@simd for i in domain. indexes[1 ]: domain. indexes[2 ]
2795
2808
@inbounds @fastmath dCpavedni = cpdivR[i]* R/ N
2796
- @inbounds @fastmath ddnidTdt = flow* (- Hs[i]/ N)/ (N* Cpave)- dTdt* (dCpavedni/ Cpave)
2809
+ @inbounds @fastmath ddnidTdt = flow* (- Hs[i]/ N)/ (N* Cpave) - dTdt* (dCpavedni/ Cpave)
2797
2810
@inbounds jac[domain. indexes[3 ],i] += ddnidTdt
2798
2811
@inbounds @fastmath jac[domain. indexes[4 ],i] += V/ T* ddnidTdt
2799
2812
end
2800
2813
@fastmath ddVdTdt = flow* H/ V/ (N* Cpave)
2801
2814
@inbounds jac[domain. indexes[3 ],domain. indexes[4 ]] += ddVdTdt
2802
- @inbounds @fastmath jac[domain. indexes[1 ]: domain. indexes[2 ],domain. indexes[4 ]] .+ = kLAs.* inter. cs
2803
- @inbounds @fastmath jac[domain. indexes[4 ],domain. indexes[4 ]] += flow/ N + dTdt/ T + V/ T* ddVdTdt
2815
+ @inbounds @fastmath jac[domain. indexes[4 ],domain. indexes[4 ]] += dTdt/ T + V/ T* ddVdTdt
2804
2816
2805
2817
# condensation
2806
2818
# dn/dt .-= kLAs.*inter.V.*cs*R*T./kHs
@@ -2814,9 +2826,13 @@ end
2814
2826
# -= d/dni(dni/dt)*R*T/P
2815
2827
# d/dV(dV/dt) -= sum(d/dV(dn/dt))*R*T/P
2816
2828
@simd for i in domain. indexes[1 ]: domain. indexes[2 ]
2817
- @inbounds @fastmath jac[i,i] -= kLAs[i]/ kHs[i]
2829
+ ddnidnidt = kLAs[i]* inter. V/ V* R* T/ kHs[i]
2830
+ @inbounds @fastmath jac[i,i] -= ddnidnidt
2831
+ @inbounds @fastmath jac[domain. indexes[4 ],i] -= ddnidnidt* R* T/ P
2818
2832
end
2819
- @views @inbounds @fastmath jac[domain. indexes[4 ],domain. indexes[1 ]: domain. indexes[2 ]] .- = kLAs./ kHs* R* T/ P
2833
+ ddVdndt = kLAs.* inter. V.* cs.* (- 1 / V)* R* T./ kHs
2834
+ @views @inbounds @fastmath jac[domain. indexes[1 ]: domain. indexes[2 ],domain. indexes[4 ]] .- = ddVdndt
2835
+ @inbounds @fastmath jac[domain. indexes[4 ],domain. indexes[4 ]] -= sum (ddVdndt)* R* T/ P
2820
2836
elseif isa (inter,VolumetricFlowRateInlet) && domain == inter. domain
2821
2837
# dn/dt .+= inter.Vin(t)*inter.cs
2822
2838
# dT/dt += inter.Vin(t)*(inter.Hpervolume - dot(Hs,ns)/V)/(N*Cpave)
0 commit comments