Commit f3ed952c authored by Hendrik Kleikamp's avatar Hendrik Kleikamp Committed by René Fritze

[notebooks] added first version of notebook with plot of 1D data

parent 63864f1a
{
"cells": [
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"%matplotlib"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"from pymor.analyticalproblems.domaindescriptions import LineDomain\n",
"from pymor.analyticalproblems.elliptic import StationaryProblem\n",
"from pymor.discretizers.builtin import discretize_stationary_cg\n",
"from pymor.analyticalproblems.functions import ConstantFunction, ExpressionFunction, LincombFunction\n",
"from pymor.parameters.functionals import ProjectionParameterFunctional\n",
"#from ipywidgets import interact, widgets"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"N = 100\n",
"\n",
"rhs = ExpressionFunction('(x - 0.5)**2 * 1000', 1, ())\n",
"\n",
"d0 = ExpressionFunction('1 - x', 1, ())\n",
"d1 = ExpressionFunction('x', 1, ())\n",
"\n",
"f0 = ProjectionParameterFunctional('diffusionl')\n",
"f1 = 1."
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"problem = StationaryProblem(\n",
" domain=LineDomain(),\n",
" rhs=rhs,\n",
" diffusion=LincombFunction([d0, d1], [f0, f1]),\n",
" dirichlet_data=ConstantFunction(value=0, dim_domain=1),\n",
" name='1DProblem'\n",
" )"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"parameter_space = problem.parameters.space(0.1, 1)\n",
"\n",
"discretizer = discretize_stationary_cg\n",
"m, data = discretizer(problem, diameter=1 / N)"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"U = m.solution_space.empty()\n",
"for mu in parameter_space.sample_uniformly(10):\n",
" U.append(m.solve(mu))\n",
"m.visualize(U, title='Solution for diffusionl in [0.1, 1]')"
]
}
],
"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.6.9"
}
},
"nbformat": 4,
"nbformat_minor": 4
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment