{ "cells": [ { "cell_type": "markdown", "metadata": { "pycharm": { "name": "#%% md\n" } }, "source": [ "# Generating a Domain\n", "\n", "A `Domain` object is the first essential component of definig a problem in TensorDiffEq. The domain object\n", "contains primatives for defining the problem scope used later in your definitions of boundary conditions,\n", "initial conditions, and eventually to sample collocation points that are fed into your PINN solver.\n", "\n", "### Instantiate\n", "```{code-block} python\n", "DomainND(var, time_var = None)\n", "```\n", "\n", "Args:\n", "- `var` - a `list` of variables intended for use in the domain\n", "- `time_var` - a `str` indicating which variable in the list of `var` is the time variable. If your problem is temporal or spatiotemporal then list the time variable here\n", "\n", "### Methods\n", "\n", "###### Adding variables to your domain\n", "\n", "In order to build out a domain object, we must define the different variables working together in the problem.\n", "A unique aspect of tensorDiffEq is that it is dimension-agnostic - there is no limit to the number of dimensions\n", "you can add to the problem.\n", "\n", "Usage:\n", "```{code-block} python\n", "add(token, vals, fidel)\n", "```\n", "\n", "\n", "Args:\n", "- `token` - A `str` by which the variable will be referenced, usually a dimension of the problem such as\n", "`\"x\"` or `\"y\"`\n", "- `vals` - a `list` of inputs corresponding to `[min, max]` of the target domain\n", "- `fidel` - An `int` defining the level of fidelity of the evenly spaced samples along this simensions boundary points\n", "\n", "```{note}\n", "TensorDiffEq uses *meshless* solvers, i.e. the domain is not solved using evenly spaced meshs across the domain, as in FEA.\n", "The `fidel` metric defined here is to facilitate generation of training points for training the solution at the boundaries of your domain.\n", "```\n", "\n", "Example:\n", "\n", "```{code-block} python\n", "Domain = DomainND(['x', 't'], time_var = 't')\n", "Domain.add('x', [-1.0, 1.0], 256)\n", "Domain.add('t', [0.0, 1.0], 101)\n", "```\n", "\n", "\n", "###### Generation of Collocation Points\n", "\n", "Collocation points for solving an ND PINN problem are automatically generated using the bounds specified in the `DomainND` object. All you need to do is specify how many you would like.\n", "If you have a large domain and require a lot of collocation points across your domain, TensorDiffEq was designed to handle your problem specifically. More information for solving large problems\n", "with large or very coarse domains are covered later in the section on [GPU best practices]()\n", "\n", "```{code-block} python\n", "generate_collocation_points(N_f)\n", "```\n", "\n", "Args:\n", "- `N_f` is an `int` describing the numbe of collocation points desired within the domain defined in your `DomainND` object\n", "\n", "Example:\n", "```{code-block} python\n", "Domain = DomainND(['x', 't'], time_var = 't')\n", "Domain.add('x', [-1.0, 1.0], 256)\n", "Domain.add('t', [0.0, 1.0], 101)\n", "Domain.generate_collocation_points(50000)\n", "```\n", "\n", "```{note}\n", "The collocation points generated are not returned, they reside in the `DomainND` object. Therefore, one does not need to allocate\n", "the output of `generate_collocation_points` to a variable. Once the `DomainND` object is passed into the solver the collocation points\n", "will be found automatically and used for generating a solution.\n", "```\n", "\n" ] } ], "metadata": { "kernelspec": { "display_name": "Python 3", "language": "python", "name": "python3" }, "language_info": { "codemirror_mode": { "name": "ipython", "version": 3 }, "file_extension": ".py", "mimetype": "text/x-python", "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", "version": "3.8.0" }, "widgets": { "application/vnd.jupyter.widget-state+json": { "state": {}, "version_major": 2, "version_minor": 0 } } }, "nbformat": 4, "nbformat_minor": 4 }