# Convert Finite Differences method to PINNs in Modulus

I am trying to get PINNs in Modulus to have the same result as when PDEs are modeled using finite differences.
The problem is, the PDEs in code A have a parameter, k that is a function of temperature and that takes a range values. I am having a problem accommodating my PINNs code in Modulus to get the same result. Below is my attempt.

This is part of code A that solves a coupled PDE using finite differences

``````> nz = 50
> dz = 1 / nz
> nt = 50
> t = np.linspace(0, 4, nt)
>
> p = np.array([0.01, 0.5, 1.0])
>
> #Initialize concentration and temperature arrays
> C = np.zeros(nz)
> T = np.zeros(nz)
>
> #Set initial condition for concentration
> C[0] = 1.0
>
> #Initialize arrays to store results
> c_results = np.zeros((nt, nz))
> T_results = np.zeros((nt, nz))
>
> #Define the Arrhenius rate constant function
> def k(temperature):
>     arrh_expr = 4.68 * np.exp(-806 / ((600 - 273) * temperature + 273))
>     return arrh_expr
> #Calculate time derivative at specific spatial points
> def rhsC(c0, c1, c2, T1, dz, p):
>     return (p[0] * (c2 - 2 * c1 + c0) / dz*2 - p[1] * (c2 - c0) / (2 * dz) -  p[2] * k(T1) * c1**2)
>
> def rhsT(T0, T1, T2, c1, dz, p):
>     return (0.01 * (T2 - 2 * T1 + T0) / dz*2 - 0.5 * (T2 - T0) / (2 * dz) + 2.45 * k(T1) * c1**2)

``````

This is part of my PINN code in Nvidia Modulus:

``````> class PFR_equation2D(PDE):
>     name = "PFR_equation2D"
>
>     def __init__(self):
>         # z coordinate
>         x = Symbol("x")
>
>         #time
>         t = Symbol("t")
>
>         input_variables = {"x": x, "t": t}
>         c = Function("c")(*input_variables)
>         Temp = Function("Temp")(*input_variables)
>
>         def k(Temp):
>             arrh_exp = 4.68 *exp(-806 / ((600 - 273) * Temp + 273))
>             return arrh_exp
>
>         self.equations = {}
>         self.equations["PFR_equation_c"] =  c.diff(t,1) - 0.01*(c.diff(x,2)) + 0.5*(c.diff(x)) + 1.0*(c**2)
>         self.equations["PFR_equation_T"] =  Temp.diff(t,1) - 0.01*(Temp.diff(x,2)) + 0.5*(Temp.diff(x)) - 2.45*k(Temp)*(c**2)
``````

I got the following error that “loss went to Nans”