<jupyter_start><jupyter_text>In this code we will solve the heat equation using PINN implemented with the DeepXDE library.The equation is as follows:$\frac{\partial u}{\partial t} = \alpha \nabla^2 u\;$ .Where $\nabla^2$ is the laplacian differential operator, $\alpha$ is the thermal diffusivity constant and $u$ is the function (temperature) we want to approximate.In a unidimensional case we have:$\frac{\partial u(x, t)}{\partial t}$ = $\alpha \frac{\partial^2u(x,t)}{{\partial x}^2}\;$, $\;\;\;\; x \in [0, 1]\;$, $\;\;\;\; t \in [0, 1]\;$.With Dirichlet boundary conditions $u(0, t) = u(1, t) = 0\;$ , and periodic (sinoidal) initial conditions:$u(x, 0) = sin(n\pi x/L)\;$, $\;\;\;\; 0 < x < L\;$, $\;\;\;\; n = 1, 2, ...\;.$This setup is a common problem in many differential equations textbooks and can be physically interpreted as the variation of temperature in a uniform and unidimensional bar over time. Here, the constant $\alpha$ is the thermal diffusivity (a property of the material that the bar is made) and $L$ is the lenght of the bar.<jupyter_code>if __name__ == "__main__":

    # Problem parameters:
    a = 0.4 # Thermal diffusivity
    L = 1 # Lenght of the bar
    n = 1 # Frequency of the sinusoidal initial conditions

    # Generate a dataset with the exact solution (if you dont have one):
    gen_exact_solution()

    # Solve the equation:
    main()<jupyter_output>Compiling model...
Building feed-forward neural network...
'build' took 0.051901 s
{'fraction_non_alphanumeric': 0.1446923597025017, 'fraction_numerical': 0.01757944557133198, 'mean_word_length': 3.7435897435897436, 'pattern_counts': {'":': 1, '<': 6, '<?xml version=': 0, '>': 4, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '1', 'dir': 'jupyter-structured-clean-dedup', 'id': '126580', 'license': 'Apache-2.0', 'n_tokens_mistral': 488, 'n_tokens_neox': 435, 'n_words': 192, 'path': 'examples/heat_conduction_1d_uniform_bar.ipynb', 'repo_name': 'zhang-liu-official/project3-pinn-test', 'size': '1479'}