Skip to content

Commit

Permalink
Add new examples
Browse files Browse the repository at this point in the history
Signed-off-by: Tom Freudenberg <[email protected]>
  • Loading branch information
Tom Freudenberg committed Oct 25, 2023
1 parent 76cbd65 commit 0c02911
Show file tree
Hide file tree
Showing 13 changed files with 6,028 additions and 10 deletions.
583 changes: 583 additions & 0 deletions examples/backup/BackUp_1.ipynb

Large diffs are not rendered by default.

382 changes: 382 additions & 0 deletions examples/backup/BackUp_2.ipynb

Large diffs are not rendered by default.

594 changes: 594 additions & 0 deletions examples/backup/BackUp_Sol_1.ipynb

Large diffs are not rendered by default.

384 changes: 384 additions & 0 deletions examples/backup/BackUp_Sol_2.ipynb

Large diffs are not rendered by default.

Binary file not shown.
Binary file not shown.
Binary file added examples/new_examples/DrillingData/solution.npy
Binary file not shown.
Binary file added examples/new_examples/DrillingData/time_points.npy
Binary file not shown.
21 changes: 11 additions & 10 deletions examples/new_examples/Exercise_2.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@
"import torchphysics as tp\n",
"X = tp.spaces.R2('x')\n",
"U = tp.spaces.R1('u')\n",
"T = tp.spaces. # <- Add the time variable \"t\" of dimension 1 (e.g. R1)"
"T = tp.spaces. # TODO: Add the time variable \"t\" of dimension 1 (e.g. R1)"
]
},
{
Expand All @@ -91,8 +91,8 @@
"outputs": [],
"source": [
"omega = tp.domains.Parallelogram(X, [0,0], [1,0], [0,1])\n",
"time_interval = tp.domains.Interval(T, ) # <-add the bounds of the Interval (0, 2)\n",
"product_domain = time_interval # <- products are define with: * omega"
"time_interval = tp.domains.Interval(T, ) # TODO: Add the bounds of the Interval (0, 2)\n",
"product_domain = time_interval # TODO: Create the product domain. Products are define with: * omega"
]
},
{
Expand All @@ -113,13 +113,13 @@
},
"outputs": [],
"source": [
"# Add the product domain of time and space:\n",
"# TODO: Add the product domain of time and space:\n",
"inner_sampler = tp.samplers.RandomUniformSampler(, n_points=25000) \n",
"\n",
"# The boundary sampler is done already.\n",
"bound_sampler = tp.samplers.RandomUniformSampler(time_interval*omega.boundary, n_points=10000)\n",
"\n",
"# Currently only the left interval side {0} is passed in the initial sampler, create the product domain with omega:\n",
"# Currently only the left interval side {0} is passed in the initial sampler. TODO: Create the product domain with omega:\n",
"initial_sampler = tp.samplers.RandomUniformSampler(time_interval.boundary_left, n_points=5000)"
]
},
Expand All @@ -143,6 +143,7 @@
},
"outputs": [],
"source": [
"# TODO: Add spaces\n",
"model = tp.models.FCN(input_space=, output_space=, hidden=(30,30,30))"
]
},
Expand All @@ -167,7 +168,7 @@
"outputs": [],
"source": [
"def pde_residual(u, x, t):\n",
" # in the differential operators you have to pass in the correct variables \n",
" # TODO: Pass in the correct variables \n",
" # for the derivative computation as the second argument:\n",
" return tp.utils.grad(u, ) - 0.1*tp.utils.laplacian(u, ) - 1.0\n",
"\n",
Expand Down Expand Up @@ -212,11 +213,11 @@
"metadata": {},
"outputs": [],
"source": [
"# Implement the residual for the initial condition:\n",
"# TODO: Implement the residual for the initial condition:\n",
"def initial_residual(u):\n",
" return \n",
"\n",
"initial_cond = tp.conditions.PINNCondition() # add the model, sampler and residual"
"initial_cond = tp.conditions.PINNCondition() # TODO: Add the model, sampler and residual"
]
},
{
Expand All @@ -238,7 +239,7 @@
"outputs": [],
"source": [
"optim = tp.OptimizerSetting(torch.optim.Adam, lr=0.005)\n",
"solver = tp.solver.Solver([.,.], optimizer_setting=optim)"
"solver = tp.solver.Solver([.,.], optimizer_setting=optim) # TODO: Collect all conditions"
]
},
{
Expand Down Expand Up @@ -282,7 +283,7 @@
"metadata": {},
"outputs": [],
"source": [
"plot_sampler = tp.samplers.PlotSampler(plot_domain=omega, n_points=2000, data_for_other_variables={\"t\": 0.0})\n",
"plot_sampler = tp.samplers.PlotSampler(plot_domain=omega, n_points=2000, data_for_other_variables={\"t\": 0.1})\n",
"fig = tp.utils.plot(model, lambda u : u, plot_sampler)\n",
"\n",
"\n",
Expand Down
Loading

0 comments on commit 0c02911

Please sign in to comment.