Epanet-Matlab-Toolkit MSX simulation 513 error

Hi,
I’m trying to carry out an Epanet-MSX simulation using the Epanet-Matlab-Toolkit v2.1.8, but I’m having some troubles with the MSX simulation.
The specific error that I get is “Error 513 - could not integrate reaction rate expressions.”, but, however, I do not find the reason for such integration error.

Below there is the msx simulation file, where I have only one reservoir:

[OPTIONS]
AREA_UNITS CM2
RATE_UNITS HR
SOLVER RK5
COUPLING FULL
TIMESTEP 10

[SPECIES]
WALL Sp UM; biofilm heigth
WALL Na log(N) ;number of attached bacteria
BULK CL2 MG ;chlorine (mg Cl/ L)
BULK S MG ;organic substrate (mg C substrate/ L)
BULK Xb UG ;mass of free bacteria (ug C biomass/ L)
BULK Nb log(N) ;number of free bacteria
WALL Xa UG ;mass of attached bacteria (ug C biomass/ cm2)


[COEFFICIENTS]
CONSTANT Ksp 40 ; bacteria/biofilm height ratio
CONSTANT Kb 0.03 ;CL2 first order decay constant by bulk demand (1/hr)
CONSTANT CL2C 0.20 ;characteristic CL2 (mg/L)
CONSTANT CL2Tb 0.03 ;threshold CL2 for Xb (mg/L)
CONSTANT CL2Ta 0.10 ;threshold CL2 for Xa (mg/L)
CONSTANT MUMAXb 0.30 ;max. growth rate for Xb (1/hr)
CONSTANT MUMAXa 0.30 ;max. growth rate for Xa (1/hr)
CONSTANT Ks 0.40 ;half saturation constant (mg/L)
CONSTANT Kdet 0.03 ;detachment rate constant (1/hr/(m/s))
CONSTANT Kdep 0.25 ;deposition rate constant (1/hr)
CONSTANT Kd 0.06 ;bacterial decay constant (1/hr)
CONSTANT Yg 0.15 ;bacterial yield coefficient (mg C biomass/mg C substrate)
CONSTANT BETA 1000000 ;10^6 (cell/ug C biomass)=(10^9(cell/mg C biomass)) constant of bacteria that are produced for each mg of organic carbon in biomass (cell/mg C biomass)
CONSTANT Kw 0.0026; zero-order kinetic constant for chlorine decay by wall demand (mg/cm2/h)
PARAMETER T  15;temperature (°C)

[TERMS]
Ib EXP(-STEP(CL2-CL2Tb)*(CL2-CL2Tb)/CL2C) ;Xb inhibition coeff.
Ia EXP(-STEP(CL2-CL2Ta)*(CL2-CL2Ta)/CL2C) ;Xa inhibition coeff.
Topt 40-((20-T)/2) ;optimal temperature for bacteria
Ti 18-((20-T)/2) ; temperature shape-parameter
Tf EXP(-((Topt-T)/(Topt-Ti))^2) ; temperature factor for MU calculation
MUb MUMAXb*S/(S+Ks)*Ib*Tf ;Xb growth rate coeff.
MUa MUMAXa*S/(S+Ks)*Ia*Tf ;Xa growth rate coeff.

[PIPES]
RATE CL2 -Kb*CL2-Kw*Av  ;Av (cm2/L)
RATE S -(MUa*Xa*Av + MUb*Xb)/(Yg*1000) ; x1000 to convert Yg in (ug C biomass/mg C substrate)
RATE Xb (MUb-Kd)*Xb + Kdet*Xa*U*Av - Kdep*Xb
RATE Xa (MUa-Kd)*Xa - Kdet*Xa*U + Kdep*Xb/Av
FORMULA Nb BETA*Xb
FORMULA Na BETA*Xa
FORMULA Sp (Xa/Ksp)*10

[TANKS]
RATE CL2 -Kb*CL2
RATE S -MUb*Xb/(Yg*1000)
RATE Xb (MUb-Kd)*Xb
FORMULA Nb BETA*Xb

[SOURCES]
CONCENTRATION R-1 CL2 0.0001
CONCENTRATION R-1 S 2.5; mg C/ L
MASS R-1 Xb 100;       	



[PARAMETERS]


[REPORT]
LINKS ALL
NODES ALL
SPECIES Xa YES
SPECIES Xb YES
SPECIES CL2 NO
SPECIES S YES

Could somebody help me to identify the error?
Thanks!

Hi @margab,

Maybe you need to increase your time step…
d.setMSXTimeStep(3600)

If I try your file with Net1 and time step 3600sec looks good.
EMT: https://github.com/OpenWaterAnalytics/EPANET-Matlab-Toolkit/releases/tag/v2.2.0

Regards,
Marios