|
153 | 153 | "source": [ |
154 | 154 | "While it is possible to create a PDE model from scratch, for this notebook we use the `Heat1D` test problem that is already implemented in CUQIpy.\n", |
155 | 155 | "\n", |
156 | | - "We load `Heat1D` using the `get_components` method. We can explore `Heat1D` initialization parameters (which are the same parameters that can be passed to `get_components` method) by calling `Heat1D?`. " |
| 156 | + "We may extract components of a `Heat1D` instance by calling the `get_components` method." |
157 | 157 | ] |
158 | 158 | }, |
159 | 159 | { |
|
162 | 162 | "metadata": {}, |
163 | 163 | "outputs": [], |
164 | 164 | "source": [ |
165 | | - "model, data, problemInfo = Heat1D.get_components(\n", |
| 165 | + "model, data, problemInfo = Heat1D(\n", |
166 | 166 | " dim=N, \n", |
167 | 167 | " endpoint=L, \n", |
168 | 168 | " max_time=T, \n", |
169 | 169 | " exactSolution=myExactSolution\n", |
170 | | - ")" |
| 170 | + ").get_components()" |
171 | 171 | ] |
172 | 172 | }, |
173 | 173 | { |
|
307 | 307 | "N = 30 # Number of finite difference nodes \n", |
308 | 308 | "L = 1 # Length of the domain\n", |
309 | 309 | "T = 0.02 # Final time\n", |
310 | | - "model, data, problemInfo = Heat1D.get_components(\n", |
| 310 | + "model, data, problemInfo = Heat1D(\n", |
311 | 311 | " dim=N, \n", |
312 | 312 | " endpoint=L, \n", |
313 | 313 | " max_time=T, \n", |
314 | 314 | " exactSolution=myExactSolution\n", |
315 | | - ")" |
| 315 | + ").get_components()" |
316 | 316 | ] |
317 | 317 | }, |
318 | 318 | { |
|
504 | 504 | "source": [ |
505 | 505 | "One way to improve the solution of this Bayesian problem is to use better prior information. Here we assume the prior is a step function with three pieces (which is exactly how we created the exact solution). This also makes the Bayesian problem simpler because now we only have three Bayesian parameters to infer.\n", |
506 | 506 | "\n", |
507 | | - "To test this case we pass `field_type='Step'` to `Heat1D.get_components`, which creates a `StepExpansion` domain geometry for the model during initializing the `Heat1D` test problem. It is also possible to change the domain geometry manually after initializing the test problem, but we will not do that here. \n", |
| 507 | + "To test this case we pass `field_type='Step'` to the constructor of `Heat1D`, which creates a `StepExpansion` domain geometry for the model during initializing the `Heat1D` test problem. It is also possible to change the domain geometry manually after initializing the test problem, but we will not do that here. \n", |
508 | 508 | "\n", |
509 | | - "The `Heat1D.get_components` parameter `field_params` is a dictionary that is used to pass keyword arguments that the underlying domain field geometry accepts. For example `StepExpansion` has a keyword argument `n_steps` and thus we can set `field_params={'n_steps': 3}`." |
| 509 | + "The parameter `field_params` is a dictionary that is used to pass keyword arguments that the underlying domain field geometry accepts. For example `StepExpansion` has a keyword argument `n_steps` and thus we can set `field_params={'n_steps': 3}`." |
510 | 510 | ] |
511 | 511 | }, |
512 | 512 | { |
|
517 | 517 | "source": [ |
518 | 518 | "n_steps = 3 # number of steps in the step expansion domain geometry\n", |
519 | 519 | "N = 30\n", |
520 | | - "model, data, problemInfo = Heat1D.get_components(\n", |
| 520 | + "model, data, problemInfo = Heat1D(\n", |
521 | 521 | " dim=N,\n", |
522 | 522 | " endpoint=L,\n", |
523 | 523 | " max_time=T,\n", |
524 | 524 | " field_type=\"Step\",\n", |
525 | 525 | " field_params={\"n_steps\": n_steps},\n", |
526 | 526 | " exactSolution=myExactSolution,\n", |
527 | | - ")\n" |
| 527 | + ").get_components()\n" |
528 | 528 | ] |
529 | 529 | }, |
530 | 530 | { |
|
736 | 736 | "metadata": {}, |
737 | 737 | "source": [ |
738 | 738 | "#### Try it yourself (optional):\n", |
739 | | - "* For this step function parametrization, try to enforce positivity of prior and the posterior samples via log parametrization which can be done by passing `map = lambda x : np.exp(x)` to the `Heat1D.get_components` method. Then run the Metropolis Hastings sampler again (similar to part 3)." |
| 739 | + "* For this step function parametrization, try to enforce positivity of prior and the posterior samples via log parametrization which can be done by initialing `Heat1D` with `map = lambda x : np.exp(x)`. Then run the Metropolis Hastings sampler again (similar to part 3)." |
740 | 740 | ] |
741 | 741 | }, |
742 | 742 | { |
|
815 | 815 | "metadata": {}, |
816 | 816 | "outputs": [], |
817 | 817 | "source": [ |
818 | | - "model, data, problemInfo = Heat1D.get_components(\n", |
| 818 | + "model, data, problemInfo = Heat1D(\n", |
819 | 819 | " dim=N,\n", |
820 | 820 | " endpoint=L,\n", |
821 | 821 | " max_time=T,\n", |
822 | 822 | " field_type=\"Step\",\n", |
823 | 823 | " field_params={\"n_steps\": n_steps},\n", |
824 | 824 | " observation_grid_map=observation_nodes,\n", |
825 | | - ")\n" |
| 825 | + ").get_components()\n" |
826 | 826 | ] |
827 | 827 | }, |
828 | 828 | { |
|
964 | 964 | "outputs": [], |
965 | 965 | "source": [ |
966 | 966 | "N = 35\n", |
967 | | - "model, data, problemInfo = Heat1D.get_components(\n", |
| 967 | + "model, data, problemInfo = Heat1D(\n", |
968 | 968 | " dim=N,\n", |
969 | 969 | " endpoint=L,\n", |
970 | 970 | " max_time=T,\n", |
971 | 971 | " field_type=\"KL\"\n", |
972 | | - ")\n" |
| 972 | + ").get_components()\n" |
973 | 973 | ] |
974 | 974 | }, |
975 | 975 | { |
|
0 commit comments