Commit 62e2ed51 by Markus Holzer Committed by Jan Hönig

### Remove interpolator

parent 43393627
This source diff could not be displayed because it is too large. You can view the blob instead.
 %% Cell type:code id: tags:  python from pystencils.session import *  %% Cell type:markdown id: tags: # Demo: Working with derivatives ## Overview This notebook demonstrates how to formulate continuous differential operators in *pystencils* and automatically derive finite difference stencils from them. Instead of using the built-in derivatives in *sympy*, *pystencils* comes with its own derivative objects. They represent spatial derivatives of pystencils fields. %% Cell type:code id: tags:  python f = ps.fields("f: [2D]") first_derivative_x = ps.fd.diff(f, 0) first_derivative_x  %%%% Output: execute_result ![](data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAD4AAAAXCAYAAABTYvy6AAAACXBIWXMAAA7EAAAOxAGVKw4bAAADiklEQVRYCdWXjZFSMRDHeYwFMNgB1wFqB9ABjhWIHZxjBQ52cFiBch1wVqBHB0cH3tEB/n8h+yYs78F7EUV3JiSb7Hd294Viu912PBRFMdVeT+N5PLsR3drT/dc4jqdDzsw0BranNQFYaoxsL3eOsm40X2swl3pyZebydaW8hHjTQwkrb1frjQjeayxKwvzFZ7EiD/lk1VDjMpBGTBZwC0/pnq21T01MDW87i5fMQcYorn87g9rakNIXIE1A2fAgujvRv2tC72nEP9HeQvyFP7sE/qxKqYwkBV9qPMrQ20gz0MzIhVdiLEsoV8i5+HyND+X0vYTj9FeNlfBZDAQ6Wxsu3qkGJURNd1hHHPRyQKozBNTekwbNzXd6ujpE1/6sKd6EXzR/rMtL9p5fIdV1A6QwXfujHFlp9mApHs5Ez+eIb/xPZvHQ9Wshyuf8ro5INLNUTlsdyD3BM9B5Xzp2NmgBD06z6IH7oX0yIXR7zaQsRlqmWNM64HM0Qg9lsydAf3nbWufoOMkjueXbwYxH+32VYdq3z1BIc+F0971PkfDaoEXHeBQ91MinkZaBjPQ5Ok7ySA++8GXpdHX9IMCP3XTwG5qSdueRlrR/dFQb4fSIOsC5qhKC/oPGFxZAjo6mPHIYO0n5QdrViVgV8N3+ZEyRAAEpEIh+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ILBXqwHHEoEdQnWwAa39Y8GHbY9x3HRpy6QQ5Pxj2oafp+qrG4XHDmfjCNtpY4pR3U7ickbJf9FsxQue9hseuEflm3Ev8RbctuYZ4xw34hU3LsA106Jr9cO+htiXhCfzCvOvAAhM/oQ126Wfdg/f+128I41Iboz4Z9k7BMzBc1TEDs2lgrdlg37speMdHzHXyCRrL9oZxuCbud4DdoA4q5UFW+zvQ2j7jYhsLylzBFw50jFF7qnA3I3O/ZvM+cUzB1EnH2+x7eF1gxruqSX3hUBPhITbelKli0NeJGTcToYQTw2HI3pSBGQ+fqswNzgzl2VM+lDO0DTZZ7DpYHUkPsthGoV8hUePKS7PaaFMoM5Bf4AbjGKhBt4FtKlZOYz9xai7j1V5+6MU2MFgiYwJ2wuOGA/Zne6t/hRlEhK+s5Y7FvZQadJfxUAnoqbOaCJrd1F6yNTfsszHHXC20yRjPenzVRzjm15nYB12HYNCxKnJ5vwu69CqX68znUV+fjRKZcNCx1KPyXsrhxPfATOVQlzJ89mSrR/B+X4TR/I/6DKiGRW3UAgwKZfT9sSjwytgxNLY4jTq2x6cZ94WdsBaCgrZmnHUPq+0Qe22oF9RGCr0yCaP2HooDx6CfnH60nIB+Dfni/wBT0Cl7uzR0hHQzG/vh0gh+ARvy78Jn1wmwgExknV09/wOzSjw8PNwGT4b4gNy0RA7+CXijTHHG47Eti5IpX3tLt5H1t/TD7xVr6xR9olZgaNsrD1wvCUJn/Muv8dC51wPr8He95nNi8PoZ7Cfr7C0qKZWP5rUUP8pGrvsv7qHl6SwSHmoAAAAASUVORK5CYII=) $\displaystyle {\partial_{0} {f}_{(0,0)}}$ D(f[0,0]) %% Cell type:markdown id: tags: This object is the derivative of the field $f$ with respect to the first spatial coordinate $x$. To get a finite difference approximation a discretization strategy is required: %% Cell type:code id: tags:  python discretize_2nd_order = ps.fd.Discretization2ndOrder(dx=sp.symbols("h")) discretize_2nd_order(first_derivative_x)  %%%% Output: stream ! %%%% Output: execute_result ![](data:image/png;base64,iVBORw0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- f_W ───────── 2⋅h %% Cell type:markdown id: tags: Strictly speaking, derivative objects act on *field accesses*, not *fields*, that why there is a $(0,0)$ index at the field: %% Cell type:code id: tags:  python first_derivative_x  %%%% Output: execute_result ![](data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAD4AAAAXCAYAAABTYvy6AAAACXBIWXMAAA7EAAAOxAGVKw4bAAADiklEQVRYCdWXjZFSMRDHeYwFMNgB1wFqB9ABjhWIHZxjBQ52cFiBch1wVqBHB0cH3tEB/n8h+yYs78F7EUV3JiSb7Hd294Viu912PBRFMdVeT+N5PLsR3drT/dc4jqdDzsw0BranNQFYaoxsL3eOsm40X2swl3pyZebydaW8hHjTQwkrb1frjQjeayxKwvzFZ7EiD/lk1VDjMpBGTBZwC0/pnq21T01MDW87i5fMQcYorn87g9rakNIXIE1A2fAgujvRv2tC72nEP9HeQvyFP7sE/qxKqYwkBV9qPMrQ20gz0MzIhVdiLEsoV8i5+HyND+X0vYTj9FeNlfBZDAQ6Wxsu3qkGJURNd1hHHPRyQKozBNTekwbNzXd6ujpE1/6sKd6EXzR/rMtL9p5fIdV1A6QwXfujHFlp9mApHs5Ez+eIb/xPZvHQ9Wshyuf8ro5INLNUTlsdyD3BM9B5Xzp2NmgBD06z6IH7oX0yIXR7zaQsRlqmWNM64HM0Qg9lsydAf3nbWufoOMkjueXbwYxH+32VYdq3z1BIc+F0971PkfDaoEXHeBQ91MinkZaBjPQ5Ok7ySA++8GXpdHX9IMCP3XTwG5qSdueRlrR/dFQb4fSIOsC5qhKC/oPGFxZAjo6mPHIYO0n5QdrViVgV8N3+ZEyRAAEpEIh+uuHWfCW+uz1DaTppUKyftNHRhocgj7rRIQr+yiyxWZGh9tai8c3L3zgsPeNL53gbnKXOBRIin9K6dWMdCV8THj7JY7txbnUkQyYYikEaNAIeMONEsC397Xrc6Ji5bXpJVUfH8bq3gZfpccR68DQeh55M6oXPmYxC+RWOa6bmSHsajjfKcH+7lTcqGQCBq3I6HOoHQ1LI0dGGh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Cbud4DdoA4q5UFW+zvQ2j7jYhsLylzBFw50jFF7qnA3I3O/ZvM+cUzB1EnH2+x7eF1gxruqSX3hUBPhITbelKli0NeJGTcToYQTw2HI3pSBGQ+fqswNzgzl2VM+lDO0DTZZ7DpYHUkPsthGoV8hUePKS7PaaFMoM5Bf4AbjGKhBt4FtKlZOYz9xai7j1V5+6MU2MFgiYwJ2wuOGA/Zne6t/hRlEhK+s5Y7FvZQadJfxUAnoqbOaCJrd1F6yNTfsszHHXC20yRjPenzVRzjm15nYB12HYNCxKnJ5vwu69CqX68znUV+fjRKZcNCx1KPyXsrhxPfATOVQlzJ89mSrR/B+X4TR/I/6DKiGRW3UAgwKZfT9sSjwytgxNLY4jTq2x6cZ94WdsBaCgrZmnHUPq+0Qe22oF9RGCr0yCaP2HooDx6CfnH60nIB+Dfni/wBT0Cl7uzR0hHQzG/vh0gh+ARvy78Jn1wmwgExknV09/wOzSjw8PNwGT4b4gNy0RA7+CXijTHHG47Eti5IpX3tLt5H1t/TD7xVr6xR9olZgaNsrD1wvCUJn/Muv8dC51wPr8He95nNi8PoZ7Cfr7C0qKZWP5rUUP8pGrvsv7qHl6SwSHmoAAAAASUVORK5CYII=) $\displaystyle {\partial_{0} {f}_{(0,0)}}$ D(f[0,0]) %% Cell type:markdown id: tags: Sometimes it might be useful to specify derivatives at an offset e.g. %% Cell type:code id: tags:  python derivative_offset = ps.fd.diff(f[0, 1], 0) derivative_offset, discretize_2nd_order(derivative_offset)  %%%% Output: execute_result ![](data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAP8AAAAyCAYAAACTfg2gAAAACXBIWXMAAA7EAAAOxAGVKw4bAAAM5UlEQVR4Ae2dj3EVNxDGbQ8FgFNBoAMSKoB0QKACoIMwVJCBDoAKEugAUgGBDnAqwLgD8v1krdDpdH/fPb+7ZDUjn05araRP2pW00j0ff/v27WjIHR8fPxfNO9G+H6L1dEfAETgcApLV6yr9tWT116FanAwRRME/csEfQmp96QwE+Zfyv8XnzfX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0BHaIgOQOd5lNvfB6La2+KLwQ+oIwYFu/hYZAQ2AHCEjeeL2G0Qw/m5yrdlB4KSBGfKTPRwAwbKEh0BCYEQHJGTvvvyve131vnRtX/R+hQaovjWjuKAAAAABJRU5ErkJggg==) $\displaystyle \left( {\partial_{0} {f}_{(0,1)}}, \ \frac{{f}_{(1,1)} - {f}_{(-1,1)}}{2 h}\right)$ ⎛ f_NE - f_NW⎞ ⎜D(f[0,1]), ───────────⎟ ⎝ 2⋅h ⎠ %% Cell type:markdown id: tags: Another example with second order derivatives: %% Cell type:code id: tags:  python laplacian = ps.fd.diff(f, 0, 0) + ps.fd.diff(f, 1, 1) laplacian  %%%% Output: execute_result ![](data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAMIAAAAXCAYAAABZEpCtAAAACXBIWXMAAA7EAAAOxAGVKw4bAAAFxElEQVR4Ae2bi3EcNwyGczcpwI8O5A5kuwO5A2VSQeQOnEkFGbkDqYPY7kBOBY7Vgd1BbHWg/N+KWHNx3D3yBN1tdOIMRYIL/sACBF97WlxfX//k02KxOFHbI+Wn6dmZ+L56vlo6Gq9W7r7yRds7Gm+WfiEQ8iwlT5UPrE11AuJC+cjaWkr1C8XzspN+ZyrfKFP2unvefaD1/qH2jsbLfSBsxtYsfOeDgJXgIleWutKh8nffvo5Wn1C8kjzJeK+M84+VUfa4xLcPbXr3UHtH43kfCH82vvOBQHQWB7zaGWQn/mWmaPGH4nlZwmdGQa+jVN9o1fK4u6ClP4H85jay1T/U3tF4+bsJe1a+W0qhPknR18qP+4ZhhTPC82HTNBWNV5BGABDMH5WvKAs8e9MUbe9oPOeIWfnuZ6dcR+pwxFbohfI3GeND4jlQSW5O0XiZAi9V3/gQn+Hcq2q0vaPxkrFn5bvBisALK3+WogTBO+VL0afJEOjfNOii8VCAJNwTZbYB7ImhzxINubdJNpi9/6TjPH2nGb87J2j0sFR9Vz60NivVxq0Re/HqPax4Q/FMl7ys0Uk8d3aLJOwVW+X6tdSFdaszgvqH2j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AIkMd7+2zgqY2fG/CxKOqjsl/oS3qrjeeOz+K/lB+CbGqM+jpSn1F5vr2lVLoStGdiNjDmzKvU4buQ8lVUgqc+zfuu4z/Udo3Pz89PxJdz5qVxpzXj1P9IfFUz5rZvfs3Jlhvx3ZyrUdWOsYnO2oF4I8FVZ+yKlFVJ/dklx95mZMeogVOGHfaWDCywKd/tZCDgDxmUxcn1yD1TFPqInzgUX/HUlyOfn1hEV7BCWbfdMhaQPX+/73b9mObqsq45rhN7XTpvE+467Zti/w9+uITdWpTEXgAAAABJRU5ErkJggg==) $\displaystyle {\partial_{0} {\partial_{0} {f}_{(0,0)}}} + {\partial_{1} {\partial_{1} {f}_{(0,0)}}}$ D(D(f[0,0])) + D(D(f[0,0])) %% Cell type:code id: tags:  python discretize_2nd_order(laplacian)  %%%% Output: execute_result ![](data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAcYAAAAsCAYAAAD/yhh5AAAACXBIWXMAAA7EAAAOxAGVKw4bAAALw0lEQVR4Ae2djZXcNBSFs3tSQAgdJB0s0AHpIIEKIB2QQwWc0MGSCjikA6ACSDqADki2g3Cv15rVaCTr15Y8e3WOx9bPk54+SfNGkj2++PTp04OQu7i4eIS41zj+wfGU10j/L85yEQIWO6Z8Mid/BX7vI6IPLFlx98ASHw+UhSDxWoATibLYMaXGcYRXarTFdcjvuMtIRd4g/gYHjeH3OK5wyEUIzI3+Bkbw5Xw8gwgN4jvEfR0RZ7S4L0MSn2U+bqx4uUQS/BrHCZDKkwzdJy/wxe2t2twpPiKSX+p/4/gSaf/wJlbgEQGwu0YAZ4f8UXFwCCfPBwj/7BDoXJwbd9TnOar4BHX+2alqkffc+BRByBASrwxYTlKw0zgGk/s4hpdmjNPMhsaQX/A8O/1G3jCBbxD1zhNNho/Q0cySjCfJA3H3UbkLE587FilX4pVCyZ9G49jPpTZ0+D65ZBi/Qu21n1jWBcjtyfxr3ZcD925DTtxDZG7DxWeZjxsrXi6RdL/GcTqrnJTD98mHbm3wZc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5EMY1/+pnQawKPn2LAs8wRhnBkehRsBnUVABIYjoHE8XJOUKSTDWMatmdS8L0EjeDQzhJ/7hrxL1Z1FNitbGYmACLQhoHHchuMoucgw9m+Jb6gCDKA7M+TjGG8Zh0H3/Tzw6JUTAREYj4DG8XhtUqyRDGMxumaC076EJzcuo5pZJB/NuPGkUZAIiMAYBDSOx2iHJlo8bJKLMqkhQAN47cngZ4Tx/1OvYBRfeeIVJAIiMA4BjeNx2qJak/8B5iFlgZRUaN4AAAAASUVORK5CYII=) $\displaystyle \frac{{{f}_{(-1,0)}} - 2 {{f}_{(0,0)}} + {{f}_{(1,0)}}}{h^{2}} + \frac{{{f}_{(0,-1)}} - 2 {{f}_{(0,0)}} + {{f}_{(0,1)}}}{h^{2}}$ f_W - 2⋅f_C + f_E f_S - 2⋅f_C + f_N ───────────────── + ───────────────── 2 2 h h ![](data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAeYAAAAsCAYAAACwlxupAAAACXBIWXMAAA7EAAAOxAGVKw4bAAAK40lEQVR4Ae2d7XHVOBSGCbMFBLaD0AEfHYQOAlRA6ABmf8E/hu0AOmCgg7AVLKQD6AA2HWTf11g3tq5kS7Z0LdmvZnRlS0ey9Eg+x5I/7tH19fWtFO7NmzcnKOdVW9ZDhL+4j/jLNm4wgNx7CFy1Qm+xb7YH820lUXz8PS02fjaHTkFfSA9khK6x7oe7Jja3/c0MT2lPxvcIX7T+AXLTIH/D/ulYSZB5B5m78B/hz+FH80BmM058/F0tNn42h05BX9AoSw9kAq+x7ge7NjZJDDNw0bC+6GIDKM6eOev91I33bNMY0yjTOH+F/wJfpUO7T+HZnpRuFXzEJuWQKLIs6YG2WzTW/eNTbPxsTMofZmNmyBnudwC/A99dgqaBPUPcCfwP1zEQz7zH8F/avNUa5bZ9bAt9ErcyPmKTZFQUW4j0wE3XaKzfsLC3xMYmYu2nmjHTmP5oDat1iGZ3yFA9HsnrKm9LceLj722x8bNZIkV6IB91jXU/29WxSTJjhkF+4mF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} + {f}_{(1,0)} + {f}_{(-1,0)}}{h^{2}} + \frac{- 2 {f}_{(0,0)} + {f}_{(0,1)} + {f}_{(0,-1)}}{h^{2}}$ -2⋅f_C + f_E + f_W -2⋅f_C + f_N + f_S ────────────────── + ────────────────── 2 2 h h %% Cell type:markdown id: tags: ## Working with derivative terms No automatic simplifications are done on derivative terms i.e. linearity relations or product rule are not applied automatically. %% Cell type:code id: tags:  python f, g = ps.fields("f, g :[2D]") c = sp.symbols("c") δ = ps.fd.diff expr = δ( δ(f, 0) + δ(g, 0) + c + 5 , 0) expr  %%%% Output: execute_result ![](data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAQUAAAAWCAYAAADJo4kQAAAACXBIWXMAAA7EAAAOxAGVKw4bAAAIKElEQVR4Ae2cjVUcNxDHgecCCFQQ6MB2KgjuwE4qsOnAvFTgBx3YqcB2OgBXEJsOTCoIvg7I/6fT6Ela7Ycuu3fAnt7TaSXNjDR/jUYfu7B7d3e3k4fd3d03KttXPPR170V3k9MNzUvekWhPJOPDUJ5N0Y2t+6b0eAjtbrHe/ChpDF6qF9fJ/MYpxFEE54pHVqZnnMOlIpM6oR2SN/4htJumUV9H1T3Wx+PwXulbRdKAcUw3l2fpPxnWc8GwT09h/E3RLfDQKjxVxPZexrzKf1YM9phMclUg4DJmiIT9yMuH5CWPjoUGh/BsgmYK3WM9JB/gmQh4ZkYoGZiY9rE/S/fR7eyxY7aKfsL5h7c17M3ieS5LdSz836x8T5k4PFPmeVzAs4ivlez77V5e3Zr39F/Fv/LRo1V4VMEWSJEV+P+EUXWPO6K+ATrOgB3XleILYfKX0gcX7jvWDw7Qjg6PgDXz7kIRWztTPJbdkSZBZQsVXNkcehLXqvJUeWIp0AATpybQgRc1DJuinUD3WJUTMmoDh0CwdJmb2e/EWM8MzU51b4R1wwm0cLxT+T+KF4lTMGJ5DM4e7BhuJdRWNC4LiYOCZDha8U+6SxjUmQqiMXQvNPeLyh4UDgUdRi+aCOvR+zkHgZqnC43Hj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AElFTkSuQmCC) $\displaystyle {\partial_{0} (c + {\partial_{0} {{f}_{(0,0)}}} + {\partial_{0} {{g}_{(0,0)}}} + 5) }$ ![](data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAQUAAAAXCAYAAAAC/1q1AAAACXBIWXMAAA7EAAAOxAGVKw4bAAAIOElEQVR4Ae2c/1XcOBDHHR4FkFDBcR2QpIJbOsjRQaADePkL/uORDrirgCQdJKkgCR0cHYRsB9z3o/Uotiyv7cXyYrzznlbSaPRjvh6NxjLJs/v7+yyk8/PzHfFmSntKX1S/CWW61jXGntJt135Dy6fQfWgdxjLfBuv1P6nYvtwKlyUhnME7JRzBP0qvxPuofGVS/xN13l95gIE6ptB9oKWPbpoN1ukfmTCu7DnxdpQ47I04rNmfnp4VIwU6qOWd8lMvoULe6bXyv4v8NmX1eSM5+pbGbNN3SBmtr3fdw/Vrjivx5jn/QnUrh6JPuj4E1k8awJbKCedfEsWuLdKnDL0s2p7KOIW5coKALIwUiBCO1GidkYEQfiN+xfO41pqffJyKk6kRXze7V91DZYTFpXgvlK6VjpSIyKZKSbGeKqgRve/E4+Bh37KnPymVHILqmWzzvbLjfL9m2zAL9J/KH9TIQJ6o5zwM2byOb19SYCNwOiYlrY11EQY5T7fiZH3rHi4DR/BWCcfwXemL0uhoJFiPDtfYgnvA+kZjtI3u2afs1+OSU2jYVHid17HFL+EdaszjJe19NeEFSStTAt39WjQ2Tov1cWmLwx2lQ8gVetRY52t8KtmDsW4LBPav9EvptOQUGEBMTrSXShgv9E08wg4uJ1p/PVAf7hJay0t27dSX7hFFDsS71fiGaURkWqyEWE8LyH61Zb8elpyCHtRnMTFef7qrPMsfINN32eRshMYTUWMTsvxkcBGb5rt4XV5RXMeH/mjOPnV3y8lxAwcihTvV+YpD7vF1ghP7SYS1u9AWlGZLHGTY7kNeKUf/ZKQ/hzwRx64SBzsX3HX7i/16sKUfR/mDypSXDFZ1BI33Ixdvk72SEO/pUdK43AHQTiTynqQyEQpOYlDS3D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Mwf+RkNaQQnfTGceaaY6YZ0bfEM+wbuMgG+JrbV36tN0YNnaved9YazzuDYh8sCWioF0ldOQLQxEX8CvWVa3U4UHIPgWswQBczDFwSIBNuKfF8kQU8fvPnNWZm1p/W+vFCgXJGNh45ptCE8VSXbLcQ2RK+5QDWficGo+CtJZedS8ohcHWYYrhYYCetI7W+Fqnjn14bnUGb0MmzfvGWuPhcL3TVZ2/T/D1XJmpYo3epTeAHI9KJtxctAWeW5XWZsaFRPAojjQIZT4JxYyNSKDVohajrfzLKRCeBCsPtqRjo+7CgT+OsQiJ+wQipgpJBkfpHkTQuHQO9ePrAbgWaWmfgiDzWWRWYHcqPgqshQGHDZ9ZvWOFJ01Idjo6xcTfYN38iDmknV2V/j+F5n4LCYFsRskfL3GZcSpedFOKz4UPrwsxp7EYcES/TbqrnU2Hrry3fVW97pNQprYoNuLX4qs2jP6r0luVfRSyrI9kHUkmOp+1P7Z8mU5qw/FyILlwWHWcA7hcq1z5NC1eVHfxJ4+1MOCw4A7CXUJvq9KZ1LlL6M/m4AGu5da7s3INHVrojpFhoOR1Fzo2CzJEUiU8l82hNk6958r5MuRpWR+E1O5OVOWjcc4NOlk0cCQ57hLQj8MpfHVAfWiD9QKH2C9YYocL4n9eSp3Ozs72lE5SzzPG8YXLFfh0WbvkZ0o7Hft0nqfL+GOQ3WBd3evC5ESpZH/JHcIYjGXda9RDuVRqvckle9Rlzcgrzbr0eaqywmGDdUMgsHEKDQANtTlkrK2dQtc1pRy761oeg3xKPFKOPRR2/wMdsuuwbt1IoQAAAABJRU5ErkJggg==) $\displaystyle {\partial_{0} (c + {\partial_{0} {f}_{(0,0)}} + {\partial_{0} {g}_{(0,0)}} + 5) }$ D(c + Diff(f_C, 0, -1) + Diff(g_C, 0, -1) + 5) %% Cell type:markdown id: tags: This nested term can not be discretized automatically. %% Cell type:code id: tags:  python try: discretize_2nd_order(expr) except ValueError as e: print(e)  %%%% Output: stream Only derivatives with field or field accesses as arguments can be discretized %% Cell type:markdown id: tags: ### Linearity The following function expands all derivatives exploiting linearity: %% Cell type:code id: tags:  python ps.fd.expand_diff_linear(expr)  %%%% Output: execute_result ![](data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAPkAAAAXCAYAAADJAeliAAAACXBIWXMAAA7EAAAOxAGVKw4bAAAHBElEQVR4Ae2ci3UUNxSGsz4U4NgdmA4M6cB04KSDmA6ckwpynA5wKiDQgaECYjrAHcTQgfN/Y0mRtJpZze7VzC5enSPrdfXrPnT1moXFw8PDD3lYLBYXqjtUPHZtb0R3l9PtYtlaNmu8XdTpVDy30HULzKn0UT0OTh5HdbxSPPF1yuPsN4pnvm5XU8lgKps1XqxXYaP3N4qXLg02iemeSl46MLUdemuBuY32yB2cHfwmZ1R1p4pf8/pdKot/U9ms8XJdCv+dIhP7XJEZeZ7TPJWyZDe1HXprgbmt9jhA2ii8UP5lVO6yYv6zMofuaJM3Ny9r3HNFdrRNgrVs1nhBNsnKLo5zc4L6oPhKNnivdCeDgf1a6LoF5lbaJ3FyTaTXij/2cMqdHMXsZLCWzRovU+oZZY3xQfEbadb+pIotdN0Cc1uN8qzEmFZejufs6PdSht9BTlQm7nSwls0azyn3J6XfxUOn5WRpoesWmJYyW2AlTu4E/kvAPPj8rXikOu6FbxUJoyee6//vY/fuL7sTx/9Jg7Vs1ngoQ5jcPTkt/aJ4rzJ2YEd/TfpUQyNds5FZz3WuWK8Uvzhb4S+cjqmbL4iB7vFNHHBE/Kp46ut8qjruhrxWXPq6Valo2fURNjwYKQ/O7aq+eTsYitVjF/pby2aKV+B3pa6lj2av7cJemgM5j2PKm9hPfc113QiTzTA8WivP/MeOfH5OHrgp016qt6gTdmK/Z4ymlRKGeM39Q4OUdll/TO/aRM8j2LEiO/Sx+vymNA849Hu1+eM+7d8Uu92JwhTBWjZrvFwHDp/q3nu4aK5inatcY49kqBV9TtR+pDF6eUjAGhXEg/m8bITZbUJSQ3jPku7uNBaawQ+SoPpp7SdmYAAHJ3NIOY+qZ4fvPqEp5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Zf3jFJg1+bIl4fBMYTL1evG47vOg32iAYaOmBHZcHYi+9XKNMxs2jqIKZ1iu9tMt9zHryVzvpPPZr+FmEnFqihJKP8LK6jZYbnnfBfBWrZVeGrnvQIH5+GzdEUKehUtu/YLnCZUKjM0htrYQT4q/qp+4deHQ308tmiY5Ozk+YT1JFuV1sg0luEhTLVx0mHuczz3NuS0FfQcjyf6Wey3lpPHjO/z02nATTgedIqTaIgT9eXfEIzqpz78iGhn/3nxkD7maJvLfnsnn8PaG4ypicJOUfri0YuKg6vxs/r5h7peWt/g+vD79b7rgyfdpyM0MIf91rmTjxBpT9pAA91nyZG4OOsYB+foyf9Gs3fwkYquIJ/cfvudvMIq20ayzs48Rgbh8+bC41Fy9x+Dsaft18DU9vsPQY57dOU2asIAAAAASUVORK5CYII=) $\displaystyle {\partial_{0} c} + {\partial_{0} {\partial_{0} {{f}_{(0,0)}}}} + {\partial_{0} {\partial_{0} {{g}_{(0,0)}}}}$ ![](data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAPkAAAAYCAYAAAA4V1u3AAAACXBIWXMAAA7EAAAOxAGVKw4bAAAHIklEQVR4Ae2c61UeNxCG1xwKIHEFIR34UkFwByQdxHQQH37BPw7pAKcCjDvAqcCOO4g7sI87IO+z1shasVcY7X4bvjlHSBpJrzQzGl1Wn/3o5uamyun09HRPvAOFfYV3yn/M66w17y2bN95a9TrHuEvougTmHLqY0sdOXllC49zHCjj2a4Vn4l0pXj15y+aNt3oFFxSghK5LYBZUwZ2hH6U7uYRmBz9W/CpFVP4P5Z8r/jXlryntLZs3Xpsu1ceF+F9D2Znylm6r/r/lldB1CcxNNUC+k7ODvwwKSMfMjn4o/pOUubK0t2zeeA11StfnYvyocKnwUoET1kOlErougbmR9smd/F+N8o0mWGPHCHl4i0w09X+gwES/D3nL5o2Xy4a8ODiO/kHhncIqycF+JXRdAnMj7bObjkrGYMfuoi8qeN5VWJi/J3zCnclbNm+8VDCcQnnk5aMni+tqHTzIdS/7ldB1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PJaa0YbFJr2EpzhzpErr2xqw/Rgf7mE7wGyh+qF7SfruMRAPg6Sa+y8IL9JP4+cSysjTGwePkUZsjBe5zODXPaBDls/8jC43BWzZXvFoz3//YaSju1t+LKpx87ALZsEeC0Zdsa4Pt6XcR8rYdQnhjCo97Nwsh851F8bECdsp/zLSY/Won14AqDZCvgI0vgfAz6nJ4HLhxhBceK+ZGUAHZXHWVKInJ0mUDdJzrP88b1C17WEELhhW1tRm7qBiGe+xtOwbojSk8FuW4MCvP+3jM06cI/eb2yvN1xVC34U9W0IJhRZ3227EaY2IN3u6kbav7rSPmGMyRdVBGl0JGQvRX85ZtLJ7q8WZ6FUbHffyyY6ToHkNGGttHbKDExDbYuWuypbBD6aL2myjT0Fjr8jGYqvNEgVeIaBd4AiDkH0gXs98kJw/aOVMcP8ZIKNK8EXpMhtBFMxI2z3Fz/DTQW7YxeFxp9iRfPVEUt+7k4rOIti2uvX2Aq0AfKfW2SSrSn123Eva0pPqfw35jZZoy+CHMY4GlvoANuY+/CvaKfYX8IvZr/KcRcUQDiWTS8GOYnxUQitV69eQt2xCeynnnZnKgR+51nYulyvhay/eORh3lzYlv2UNl7Cp/K/yudFxA+tqobk2q09qflW9aPEamqWPuw1QZDn6kYHdx7MjOnh/V627Fb9XnQB/3tl/F/wyzDevQwcnJyYHC+V3spXaHU9qp/p7C9ZQ227r980j6XMR+dzmu16vS9s/8Ggg7BMfvtmNf54BUnx2ndXfpbPTthzfsUlty0sBS9ts6uZMB54LRRMHxOLJzNBxL/CR49HVKdblCcOxsXAvGdrat160B6XR++22PWP1HrE3VD8fpUmMriV1qzGvDLanjHPs/3HftqL6VlNMAAAAASUVORK5CYII=) $\displaystyle {\partial_{0} c} + {\partial_{0} {\partial_{0} {f}_{(0,0)}}} + {\partial_{0} {\partial_{0} {g}_{(0,0)}}}$ D(c) + D(D(f[0,0])) + D(D(g[0,0])) %% Cell type:markdown id: tags: The symbol $c$ that was included is interpreted as a function by default. We can control the simplification behaviour by specifying all functions or all constants: %% Cell type:code id: tags:  python ps.fd.expand_diff_linear(expr, functions=(f[0,0], g[0, 0]))  %%%% Output: execute_result ![](data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAMIAAAAXCAYAAABZEpCtAAAACXBIWXMAAA7EAAAOxAGVKw4bAAAGJElEQVR4Ae2bj1UcNxDGc7wUQOwOcAfY6QB3gEsI7oC8VJBHOoAOErsDnApi6MB0EJsOyPcTmrV2TrunPYbbC4feE5JGM59GM/q/x+Lu7u4HHxaLxYlo+4ovc925+G48X2s5Gq+13V3li7Z3NN5W+oWJUEYpeaZ4YDTlmRCXikdGm5JKLhTPt531O1d6qkja6e55d6Gs/ofaOxpvW33gJwE7waVXVrRDxW+evqosmVC8Wntq44Mizj9WZHs7rvHtAk19D7V3NN42+2BPnS3DaxXelATy6sC1kv28RfrqsXI0Xq8t6cNuxQRgx/qk+Fa6flT6vwvqy7Eiu9pDQrS9o/Ee0rdHle1NBA2i94o/DbTIHQHDNIdovErDR9DUzifFW9IKz86Qou0djbfNjvixppxWJo5C7AxfZQxbYQ9UJk4O0XiFAj8rv/YlvsB5Utloe0fjbaOxezsCHVa8kqJMgr8Ur1U+y4ZA/0mDLhoPBQjCPVHkYsyZmPJ5LlPc2SAbbL3/pCNHQPx1miNljrbzBq346cIsLThmfFM8NJqloqEoF9FTo61KxRuKV2uvRSfxPNorkrCXbFXTs4UmLO46zfb1mJINtXc0Hvoq8KjRPcYozwmDCp7new83mX9jvktHI81IFOL15XcpwMXYBzsSpTpmshheKv5LKplfS4FovBLb8rkNioP3AvGclbqt0tuwy3SFzIHqX6iNQR1KrMfKS4et9590TBNdNujuoLLbjeiYZWlHEH2zvpMyKMIkILNP2UfR2SnS86lSjiMoaTsJHfxgZVLKimF4JbblhU+7Ki7rC00BHboVRfmVenusFhnxTPp2IX5WRY6fPn4RDTt7OuWefSt6htqb9hRD/Sc8+tbtBtlH3EWX2hFt476zwYwyV97AWVmeKKlP27ZSHNb7uJbru0mUy2F4A3oxoL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zsZTnX0Vb1WGAT1lErDV819xz5Og1cJtfBv33ZPdEbD3Oit8m5/uuYTP/YFL3+0UuWfe1RbYtO/+AzbHtOfb64fzAAAAAElFTkSuQmCC) $\displaystyle {\partial_{0} {\partial_{0} {{f}_{(0,0)}}}} + {\partial_{0} {\partial_{0} {{g}_{(0,0)}}}}$ ![](data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAMIAAAAYCAYAAACoRCJ4AAAACXBIWXMAAA7EAAAOxAGVKw4bAAAGLUlEQVR4Ae2b7VEcORCG1xQBUOcIjsvAHxEczoALwSaDc/EL/rlwBrYjwDgD7Ah85wzOGdhFBtz76NQ6jRjtaIbenYVFVUJfrbdb3eqWRsCj6+vrRZlOT0/31HegvK/8We1vJc2YtjfeGN7bSOutb2+8TbTJTimUFo0DHCuz+d8rP1PfhcpJyRtvkhBbNMlb3954m2qKR/mJoEVzEhyrfJ0LrPafaj9X+UfeP1T3xqvxE593GruK42/Utnptyr3s99a3N94mK708ETgJXkUF5HJzMhyq/0ne2VD3xrvBUjKdqfMX5XPlV8qcaNuavPXtjbexdikd4R9J+lGbqxNRY5u+sZvMG69PkWx+nABn+Ev5s/KdS9LxgTJruU3y1rc33m3WttK5uzm6DEHkr6WfGnheG+zr98YrebB51LenzAc9jnonnSCui3WQJydvfXvjTV7YGiZ2HAF+WjxR6akyG4v0VX2fVO4rf6djTPLGK3i/UPu7eJisxfD2Nb317Y23qRbpOIIWfRk31pEJrL78yB7lCN54mUw4K07AifBTfHjVokxyq711yVvf3ngYRJiHKrhZ/KCtRJBljy27jQTCVf7YMfC4aATtbCa1uW5Y399GP1R64+X8hP1emRcsrhLvqCubjDnp1tS1foLYotSD2htjP8nCw0Z4lVT9reo4AXtq1Guk6N1TcAQJRYQlunaeTTNudnf9mPVVq954fYzEYz/2V78LRMNLl9H1wdyqT9g8K8+eJMfG2w9bSFHo63dTmPq4YbC3ghNbPyX0ymuznV2NcIArMa79BhmBPmk83MVV4tkkjrfHapcO5I0XmBU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ZzgSNm+DbAhJ0R5LQos1d+rywEet7bdgv9Qu2/55OTkQPlsyro073DMPNHvKV+OmfNAW99z0uUstptyNQqeu8k/YrThqtN3zFZFFz3RqzdSVSfpdNIYEe8hOWhgLtvdS0fAHlIom5PrEUdxa+JPHJqveKLlusYxX72mtTJ+oPtfA9Ln+m13349pri6rWuMqsVcl813CXaV+S+x/AQ3mxxrhRin1AAAAAElFTkSuQmCC) $\displaystyle {\partial_{0} {\partial_{0} {f}_{(0,0)}}} + {\partial_{0} {\partial_{0} {g}_{(0,0)}}}$ D(D(f[0,0])) + D(D(g[0,0])) %% Cell type:code id: tags:  python ps.fd.expand_diff_linear(expr, constants=[c])  %%%% Output: execute_result ![](data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAMIAAAAXCAYAAABZEpCtAAAACXBIWXMAAA7EAAAOxAGVKw4bAAAGJElEQVR4Ae2bj1UcNxDGc7wUQOwOcAfY6QB3gEsI7oC8VJBHOoAOErsDnApi6MB0EJsOyPcTmrV2TrunPYbbC4feE5JGM59GM/q/x+Lu7u4HHxaLxYlo+4ovc925+G48X2s5Gq+13V3li7Z3NN5W+oWJUEYpeaZ4YDTlmRCXikdGm5JKLhTPt531O1d6qkja6e55d6Gs/ofaOxpvW33gJwE7waVXVrRDxW+evqosmVC8Wntq44Mizj9WZHs7rvHtAk19D7V3NN42+2BPnS3DaxXelATy6sC1kv28RfrqsXI0Xq8t6cNuxQRgx/qk+Fa6flT6vwvqy7Eiu9pDQrS9o/Ee0rdHle1NBA2i94o/DbTIHQHDNIdovErDR9DUzifFW9IKz86Qou0djbfNjvixppxWJo5C7AxfZQxbYQ9UJk4O0XiFAj8rv/YlvsB5Utloe0fjbaOxezsCHVa8kqJMgr8Ur1U+y4ZA/0mDLhoPBQjCPVHkYsyZmPJ5LlPc2SAbbL3/pCNHQPx1miNljrbzBq346cIsLThmfFM8NJqloqEoF9FTo61KxRuKV2uvRSfxPNorkrCXbFXTs4UmLO46zfb1mJINtXc0Hvoq8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o5wOQ5eGn4WHpUpGhjb0gu24Sz2e4ANh4GXa1r7tCxZp4ziyZ747crZlbvnhfrrd4TZfLeQMvXujVDVKfuyDBerGGfKtUMLnnh4xmUScKmvHdu69sXLqvfaD6yxdlTHavS34i+Ssx8a8vS6sq/iYTCwI3jHirx9oaVPU7Qew1MduyXjg6OQ+Y8du7Nx2Zb4Z/HdWhOhVHwb89kxXMSqxh7TWbL8Y88kOcnw8XDST9THdNjlurl89yQnAgNJBmXVqb14DY4zJoEqryVnl61BXqvIMvzeaOioZqzPaaMF5vDdOneExu7MzsZTnX0Vb1WGAT1lErDV819xz5Og1cJtfBv33ZPdEbD3Oit8m5/uuYTP/YFL3+0UuWfe1RbYtO/+AzbHtOfb64fzAAAAAElFTkSuQmCC) $\displaystyle {\partial_{0} {\partial_{0} {{f}_{(0,0)}}}} + {\partial_{0} {\partial_{0} {{g}_{(0,0)}}}}$ ![](data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAMIAAAAYCAYAAACoRCJ4AAAACXBIWXMAAA7EAAAOxAGVKw4bAAAGLUlEQVR4Ae2b7VEcORCG1xQBUOcIjsvAHxEczoALwSaDc/EL/rlwBrYjwDgD7Ah85wzOGdhFBtz76NQ6jRjtaIbenYVFVUJfrbdb3eqWRsCj6+vrRZlOT0/31HegvK/8We1vJc2YtjfeGN7bSOutb2+8TbTJTimUFo0DHCuz+d8rP1PfhcpJyRtvkhBbNMlb3954m2qKR/mJoEVzEhyrfJ0LrPafaj9X+UfeP1T3xqvxE593GruK42/Utnptyr3s99a3N94mK708ETgJXkUF5HJzMhyq/0ne2VD3xrvBUjKdqfMX5XPlV8qcaNuavPXtjbexdikd4R9J+lGbqxNRY5u+sZvMG69PkWx+nABn+Ev5s/KdS9LxgTJruU3y1rc33m3WttK5uzm6DEHkr6WfGnheG+zr98YrebB51LenzAc9jnonnSCui3WQJydvfXvjTV7YGiZ2HAF+WjxR6akyG4v0VX2fVO4rf6djTPLGK3i/UPu7eJisxfD2Nb317Y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r4n+qLfjWvKEOYYPNHyrnwRMfk+OK/gIyMLTmkMH5s0cg76qBnFIIdKDF4z+tDcpvGRaxrEbMETzRNlXtaSTegTOLl80JjNdqMcIWrmjcr0YahFUed9eOpGaMXjNWHPFKqy90RQPw7Z56hL+YCrDI88LZ2TEcKPv9ScnMSbPxxcx58ZtK6pdS1DeMcCyvcLDsH3wWuttxM8Y3sW23X+Mad15RLYNgy/UPstLmpyNGvBEw2/B0CJ8OOuWXU8jfEScVTSqF2VW2NEqC/KL1VPTrZsjmhDEk0vPxvftLJlTWNkXoanMZzgSNm+DbAhJ0R5LQos1d+rywEet7bdgv9Qu2/55OTkQPlsyro073DMPNHvKV+OmfNAW99z0uUstptyNQqeu8k/YrThqtN3zFZFFz3RqzdSVSfpdNIYEe8hOWhgLtvdS0fAHlIom5PrEUdxa+JPHJqveKLlusYxX72mtTJ+oPtfA9Ln+m13349pri6rWuMqsVcl813CXaV+S+x/AQ3mxxrhRin1AAAAAElFTkSuQmCC) $\displaystyle {\partial_{0} {\partial_{0} {f}_{(0,0)}}} + {\partial_{0} {\partial_{0} {g}_{(0,0)}}}$ D(D(f[0,0])) + D(D(g[0,0])) %% Cell type:markdown id: tags: The expanded term can then be discretized: %% Cell type:code id: tags:  python discretize_2nd_order(ps.fd.expand_diff_linear(expr, constants=[c]))  %%%% Output: execute_result ![](data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAcUAAAAsCAYAAAAU/aN6AAAACXBIWXMAAA7EAAAOxAGVKw4bAAAMIUlEQVR4Ae2di5HUOBRFGYoABjYDyGCADJgMgI0AyABqI9iCDAYi2IIMYCMAJgPIYGEyYO81kketlm39bKvdV1Vu2/o+Hen5WZLdPvn169eNIXdycnKKsNfYvmG7x2PE/4693AQBhx1j3jXRX4Hf5UTSG05acQ/AEp8AFHnNQsDpa8w/SY9nEUiZzk7g5kQJ7xB+hY2G8Dm2M2xyEwSMIr2DAXxhtnMkoTH8irBHE8kZLO7jkMRnnI9CKxCooMcVpFAW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2ABo6f/klxfO9ND9qkEGswLi+q5sLaoHQSKYGAdDgBVotR9Z5iI62CUSJf6KZBvB17cUSa7iO8iL/IV0saQSUxRKBJAtLhJpslWSiNFJORzZbgHDnzn0vsGuFoQVDA7gPFMoijmBQoAksSkA4vSXumsrSmOBPYjGw5UvwEY8cn0/h3X3wPkUr2AoZv5/NZ5o70njWI5vwHzpO/PYn85URABOoQkA7X4bhqLpo+XRX/78Jh1GgAf2KjUXtijSD8+Q4iH8Tp//cSflyzeIeNr2JYx+lTposaZdpE2ouACNQhIB2uw7GFXDRSbKEVrv8g+pk1iI5YNJiu44v69OsMpg2QQbQktBeBVQhwlEgnHf7N4WB/tabYRtNxmvQShs2f/qSi7TyNijh8EIcj/J2tjWpIChE4WgLS4Y00vYxiGw3ZrUW4omA65i7OOSLU+2suGB2LQJsEpMNttkuyVDKKycjqJjBrETSAOyNCnHOdkE+j+qPHugIoNxEQgSIC0uEifM0lllFcv0meUgQYP39EyFcuPjAMSvfcKB5P5URABNoiIB1uqz2KpJFRLMJXJXG3FhHIiVOndvTI1y+uAnHkJQIisD4B6fD6bVBNglvVclJGuQRo/C4Cid/Aj/+HegaD+CoQLi8REIE2CEiH22iHKlL8DwKWU19YV4/fAAAAAElFTkSuQmCC) $\displaystyle \frac{{{f}_{(-1,0)}} - 2 {{f}_{(0,0)}} + {{f}_{(1,0)}}}{h^{2}} + \frac{{{g}_{(-1,0)}} - 2 {{g}_{(0,0)}} + {{g}_{(1,0)}}}{h^{2}}$ f_W - 2⋅f_C + f_E g_W - 2⋅g_C + g_E ───────────────── + ───────────────── 2 2 h h ![](data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAeUAAAAsCAYAAABboKCqAAAACXBIWXMAAA7EAAAOxAGVKw4bAAAL5ElEQVR4Ae2d7ZWWOBiG1WMB49jB2IEfFezYgR8VOHagx1/6z+N2oFuBqx2MW8GqHWgHjtOBe99sQAgJkBDeBLhzTl4g37mSPA8Jgffqr1+/rqQwr169OkE6z01ad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FYcuuKp+XrdbUXZ7uvh4qMgWv/lzOVNP/+jv9NK7NRAmjfsZu1jdZ8l9WSHNhws2umvJLGhdCtl6QnC1/E4eDl+6t3VlJNFVMERGCAgOTAAJyNeEkpr6chq+VrDMpJS5QId4Kq8Xnynalx1oNCJRWB3RKQHNh40+uLXitpYChW7qDms+Jz2GNY7qbmTJh/bdn5y0mjkJ/jWO3CNtdXcOyEQ1wZERCBFRHAGJYcWFF7xRRVz5RjqB04DgYi3z2mAqbhqw6VcsXxA69hH9KDBm6cIfM1KCrlOg6V83NYGREQgZUSwHiWHFhp24UUW0o5hFa+sPXzZH4ExJ7tcqC2De+k6cZjYxCvmjU3DjoRARFYGwHJgbW1WER5pZQjoGWIwudI/Kcfewc1Z8If2+VBmBvta52LgAhshoDkwGaa0l8RbfTysynJh3fInV3XUL5cpqZ9X1JBVRYREIHFCEgOLIa2nISllMtpC2dJoHy5FE3lyw1ebcPlaH5UxJ49t8PoXAREYAMEJAc20IgTqyClPBFUxmCPmDcGZWemDKcz2OpDIfDjpzWpuGVEQAS2SUByYJvt2quVlHIPSXEOfI5kK2QWkjPoeun6FpSyvQGMYWREQAS2QUByYBvtOFoLbfQaRZQ9AJUvX32yDV9xegxlfAqr151sOroWgW0RkBzYVnt6a/MfM2R8O7RQA3cAAAAASUVORK5CYII=) $\displaystyle \frac{- 2 {f}_{(0,0)} + {f}_{(1,0)} + {f}_{(-1,0)}}{h^{2}} + \frac{- 2 {g}_{(0,0)} + {g}_{(1,0)} + {g}_{(-1,0)}}{h^{2}}$ -2⋅f_C + f_E + f_W -2⋅g_C + g_E + g_W ────────────────── + ────────────────── 2 2 h h %% Cell type:markdown id: tags: ### Product rule The next cells show how to apply product rule and its reverse: %% Cell type:code id: tags:  python expr = δ(f[0, 0] * g[0, 0], 0 ) expr  %%%% Output: execute_result ![](data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAH0AAAAWCAYAAADts5O8AAAACXBIWXMAAA7EAAAOxAGVKw4bAAAFrElE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96x2a/xmwEXbXpEtsUDBHLVBmx6MhWqmwW5mirWxulR9w94e7FXG1EH3030yWzuXZ5AbjZ5/PrWb5J+m2kstKwZoPHdi9VBlK2zB7lDBoDagy1YRiS65K5RrAtYONFNp/TRlKY2zTvBXcX5gpSqLyoX8bbu69N6R0543rCuMoi5e04Zr2klEe+z70LJwfI4FqwTjoKM371lmuW/cjehiHOTZVpDTRtQfEEOKM2sx5T5C0/KomlXLPswxJI3tJ21VRDRxxvk2nFHAWq2hPpMDjdATbhzTPdPh0rCZ64OSP9spiv9eH1HrCgPLVd8OZdjdi1rsZwg4nQNRpDFJoh4/5aHYEugzMFKH3fz1O/WvM+cHdiFhM4w+kk/r0K5JTqDcxGTCCU2PYVps1I3mBrjw2F4PWDRTwFfJ6Xt2HZ5DNYAtgw8POnFwNyS4pr59QrkzPSds3ahyX0Gby+GqUgdAw+S+3tgvH7wN3ADK6cfIQHm0x2Ohvy3dwPMh5xfqTwkvcXpUHM+0nSP+KXjnNxHRMMSN2V6eo0s2vy9IcwyL+Gz4tooBEykdW67fQ5ZjwPdrH7PPd7RdtJdte42zADL2W5fgifiB+G0Yk/CBs1Y8mgMKsFFSk4nY51fDOIc2Utj6dFbc0+DJUT/GtdcrpK+2Scl+CJgVieXDGbDSaf5fLp8PJoV410Z7h7MG+QbE6inyeu/zmz7XJycrKiHM1dB9lzdUyRh3+fspwiI++ctbrWmKNrDu6+dZg7otRst3WHdxlk6jjAzyijnQjvesYaa+T2p8r18W8bt/ucivl/43QNy+ZGO73PEV1z29K/Lb1zbfIfzLr+GVLUm+IAAAAASUVORK5CYII=) $\displaystyle {\partial_{0} ({f}_{(0,0)} {g}_{(0,0)}) }$ D(f_C*g_C) %% Cell type:code id: tags:  python expanded_expr = ps.fd.expand_diff_products(expr) expanded_expr  %%%% Output: execute_result ![](data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAPQAAAAXCAYAAAA8/2LSAAAACXBIWXMAAA7EAAAOxAGVKw4bAAAGg0lEQVR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cryHin5Aj+E7Vx+myoRx/H2vZq43g68x7jEYV5tUZP7EBy9+oqrtAo7bAyi34Ve2+bHv6BpfCJUnGCfkus8D+W9E3n5+dHSpd9+UM+9TsOn7vK4j9Quuni20W79JrtkPCb2TYP1TZtgP9rPI8VInRv0k5GFOMVuhaluwSIn9fZ+HCpqxs74mkX0y7aZzukrT7bxv/QY1s4YTE8VgYBmp5aMEDGzwvNNzd1PehQ/L0PZMTLTzU5pPqjA7Eeeq3NIt1mOySsN9tmOzjB/LJ1HSvrvrIS5tft29Uvp+yusYe259Q1p+yh81yHP6f+OWWvM9dUn9x6xvL/B4h2hVR2GmXBAAAAAElFTkSuQmCC) $\displaystyle {f}_{(0,0)} {\partial_{0} {g}_{(0,0)}} + {g}_{(0,0)} {\partial_{0} {f}_{(0,0)}}$ f_C⋅D(g[0,0]) + g_C⋅D(f[0,0]) %% Cell type:code id: tags:  python recombined_expr = ps.fd.combine_diff_products(expanded_expr) recombined_expr  %%%% Output: execute_result ![](data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAH0AAAAWCAYAAADts5O8AAAACXBIWXMAAA7EAAAOxAGVKw4bAAAFrElEQVRoBe2a/1UUMRDHuXsWANoBdoBYgdgBlgB0gM8KeNABWIFiB0AF6nUgVqDSAX4/IbMks9klu9yPf27eC9kkM5NvZiaT7B6T+/v7DU+TyeRQfZsqr+LYufhuPV9tW/q2xbsnHRe1Mmu++VhAtt+XplnmP5yeFjGcqmxbn55x/pUKTst4a9omP4D3XDLHKtQNjhr5NU/ZP7LjZWrLqRoNxR2+I+M1u1rPd2L4qILgGLqR0FGl4GfxMR/zk212VNb0fAscSEXjv8zpGnijsuvnkONn6tuMQeGHO9uR/0caRF3M4iWjkIrIKtcq7yX3TfWanmmBuHGvZWMy6MZEHVUqJfBLjNfir921G1EG5zWZo2sy8eLwS/FOunjW/eMtIPuyqX7LvlsvSmrEQFplx/8Vk+02LmOUKpKOwCv5Jx0eFb5VXctbhWHN9GgB+eFOPrlV2cv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ds3ahyX0Gby+GqUgdAw+S+3tgvH7wN3ADK6cfIQHm0x2Ohvy3dwPMh5xfqTwkvcXpUHM+0nSP+KXjnNxHRMMSN2V6eo0s2vy9IcwyL+Gz4tooBEykdW67fQ5ZjwPdrH7PPd7RdtJdte42zADL2W5fgifiB+G0Yk/CBs1Y8mgMKsFFSk4nY51fDOIc2Utj6dFbc0+DJUT/GtdcrpK+2Scl+CJgVieXDGbDSaf5fLp8PJoV410Z7h7MG+QbE6inyeu/zmz7XJycrKiHM1dB9lzdUyRh3+fspwiI++ctbrWmKNrDu6+dZg7otRst3WHdxlk6jjAzyijnQjvesYaa+T2p8r18W8bt/ucivl/43QNy+ZGO73PEV1z29K/Lb1zbfIfzLr+GVLUm+IAAAAASUVORK5CYII=) $\displaystyle {\partial_{0} ({f}_{(0,0)} {g}_{(0,0)}) }$ D(f_C*g_C) %% Cell type:code id: tags:  python assert recombined_expr == expr  %% Cell type:markdown id: tags: ### Evaluate derivatives Arguments of derivative need not be to be fields, only when trying to discretize them. The next cells show how to transform them to *sympy* derivatives and evaluate them. %% Cell type:code id: tags:  python k = sp.symbols("k") expr = δ(k**3 + 2 * k, 0 ) expr  %%%% Output: execute_result ![](data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAGYAAAAZCAYAAADDq1t2AAAACXBIWXMAAA7EAAAOxAGVKw4bAAAFHklEQVRoBe2ZjXUTORCAY14K4KAD0kE4KrjQAT8VQDrgSrhHOuCo4A46INfBJR0kHQDuIHyfLK0lWbvedcyLnYfem5U0OzOaH0kzXs9ubm4O9qHNZrP36PkVOAIeAW/QfU5/L9uDfbCKoHxAzysCcQacMv4GfNoH3TfVcS8CE43zpKR2weAkTe5jP9uXqyx3fjxBT9D9eY6/T+PDfTOGoDxE51fAH/um+xR9m4HB+LcI0QGPo7AP7M7rKYJzWuQ9YX6CjL9z/NQxct7B8xr4C1mXU/l3lR67XqDbZeFjJgc5QGD14zUR8IwN0BdAxxa0Y+aJv6ZNePrvgIl9tGzo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oQ69mh4IvOu6bvrT+Uz7bj+ZDI1WVSxoy1UBMN/tEWL5axLLYaH7v4edC6Dv4FMIw+Qo3ltiAAAAAASUVORK5CYII=) $\displaystyle {\partial_{0} (k^{3} + 2 k) }$ D(k**3 + 2*k) %% Cell type:code id: tags:  python ps.fd.evaluate_diffs(expr, var=k)  %%%% Output: execute_result ![](data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAEMAAAAWCAYAAACbiSE3AAAACXBIWXMAAA7EAAAOxAGVKw4bAAADIElEQVRYCdWYgVFbMQyGkx4DhG7QsAFtN4ANaEdoNoARerABjFDYoOkEbdkARqDZgH6fa706jssFyAuvujO2ZMlP/i3JDuP7+/tRnzQej09Zf0Kb0m5pJ3xzQT84GvcJRgbinG8Iwgj+km4K/3ZwSODQq56dOqrW/wy/DyhGyeCobzDccLnxSI9SNhhQdvr0hHTYq9bfz/yPSj4IdhuRUW7UYjr8AprzeFZ47ila/K4KmUXQm8FC+I521zj9Ur0bY5duFfTLb3Tz2xhk3/VDilT1cK6ThEFMuPFRNIQWPyc/hazskf+kLdmU8+XYNdbVLe02Oeb76RDLNZEJjHs8UJ42D3OchUeVsoo3pSzGLf2YK3v0DminIcv8fvCP6bH1gI4fYxO62J3TJsFHj+yXTT5qhmFipY9qz7CjFRnh5gal+Z+u/Rc9U030vzM+sjE+oaV3B/026SMfM5prcg8TfJum2wRUFOyWWtlxRSJa0yGCW+xWgKoUv8FPaNaYjtaw63Q3OPAAfOMYHS2/J82rVQMMPdEzDC8aDhkZXVRk4F4j82VpSqSTp18CuLHO1kT48q9Xb1z3t5EmySk2NaUJguHkZn0xLlEGygW+OgFvvTHNBMBCGSnEcNiE7/rqreKhL7rbA2ZpjIKbtLikShvz8HHLGD3qpKJkT2vePGH73J71n1xAW99mvRvaZcw9+EMN5ARDeoNByjNk1hCL0RdkvbwZ+IbR2YowATcdWwXYGvaBubUo78MA+LsHGI0NFX9N1tFhKqjQXbmME5r0RoXzT7rq6m+tw/OtjURG9n3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uhn9b4RsO/GbCnZ2TQ2323ymBRA/Yi+0qh3SP4coZftvqp3VCDoNZNZ5VlolFivjXkzQAfT3tuCr5pQNhvYYNFbpbqQNwk/FLAej/PW9AaCDfKMolaR2kW9ELRW2MX8BpsmllKEczehQNSYKsB3YHWLIKPt08GwxKwdqIUGtv3C599wPIQcpwN1gCNWO9rbrCAfV7aATSf5GmrAXqMMoHpKnXMCWbKGXwGybSyNnPMMMCyET78IcP7xWYvzEy28XffTr5sryIYMDeggnaSi+PN3rhmcC5yzHwfXgbSgD20upwzIOpfB31a9JyPnvfs12RAjoQpBNxsfXUD7fNrvU8xULnl2S3RNzP1N/jzMT/6sRbgAAAAAElFTkSuQmCC) $\displaystyle 3 k^{2} + 2$ 2 3⋅k + 2 ... ...
 ... ... @@ -228,8 +228,7 @@ class KernelFunction(Node): @property def fields_accessed(self) -> Set[Field]: """Set of Field instances: fields which are accessed inside this kernel function""" from pystencils.interpolation_astnodes import InterpolatorAccess return set(o.field for o in itertools.chain(self.atoms(ResolvedFieldAccess), self.atoms(InterpolatorAccess))) return set(o.field for o in itertools.chain(self.atoms(ResolvedFieldAccess))) @property def fields_written(self) -> Set[Field]: ... ...
 ... ... @@ -4,7 +4,6 @@ from pystencils.astnodes import Node from pystencils.backends.cbackend import CBackend, CustomSympyPrinter, generate_c from pystencils.enums import Backend from pystencils.fast_approximation import fast_division, fast_inv_sqrt, fast_sqrt from pystencils.interpolation_astnodes import DiffInterpolatorAccess, InterpolationMode with open(join(dirname(__file__), 'cuda_known_functions.txt')) as f: lines = f.readlines() ... ... @@ -76,30 +75,6 @@ class CudaSympyPrinter(CustomSympyPrinter): super(CudaSympyPrinter, self).__init__() self.known_functions.update(CUDA_KNOWN_FUNCTIONS) def _print_InterpolatorAccess(self, node): dtype = node.interpolator.field.dtype.numpy_dtype if type(node) == DiffInterpolatorAccess: # cubicTex3D_1st_derivative_x(texture tex, float3 coord) template = f"cubicTex%iD_1st_derivative_{list(reversed('xyz'[:node.ndim]))[node.diff_coordinate_idx]}(%s, %s)" # noqa elif node.interpolator.interpolation_mode == InterpolationMode.CUBIC_SPLINE: template = "cubicTex%iDSimple(%s, %s)" else: if dtype.itemsize > 4: # Use PyCuda hack! # https://github.com/inducer/pycuda/blob/master/pycuda/cuda/pycuda-helpers.hpp template = "fp_tex%iD(%s, %s)" else: template = "tex%iD(%s, %s)" code = template % ( node.interpolator.field.spatial_dimensions, str(node.interpolator), # + 0.5 comes from Nvidia's staggered indexing ', '.join(self._print(o + 0.5) for o in reversed(node.offsets)) ) return code def _print_Function(self, expr): if isinstance(expr, fast_division): assert len(expr.args) == 2, f"__fdividef has two arguments, but {len(expr.args)} where given" ... ...
 ... ... @@ -11,9 +11,9 @@ from pystencils.cpu.cpujit import make_python_function from pystencils.data_types import StructType, TypedSymbol, create_type from pystencils.field import Field, FieldType from pystencils.transformations import ( add_types, filtered_tree_iteration, get_base_buffer_index, get_optimal_loop_ordering, implement_interpolations, make_loop_over_domain, move_constants_before_loop, parse_base_pointer_info, resolve_buffer_accesses, resolve_field_accesses, split_inner_loop) add_types, filtered_tree_iteration, get_base_buffer_index, get_optimal_loop_ordering, make_loop_over_domain, move_constants_before_loop, parse_base_pointer_info, resolve_buffer_accesses, resolve_field_accesses, split_inner_loop) AssignmentOrAstNodeList = List[Union[Assignment, ast.Node]] ... ... @@ -73,7 +73,6 @@ def create_kernel(assignments: AssignmentOrAstNodeList, function_name: str = "ke ghost_layers=ghost_layers, loop_order=loop_order) ast_node = KernelFunction(loop_node, Target.CPU, Backend.C, compile_function=make_python_function, ghost_layers=ghost_layer_info, function_name=function_name, assignments=assignments) implement_interpolations(body) if split_groups: typed_split_groups = [[type_symbol(s) for s in split_group] for split_group in split_groups] ... ... @@ -146,8 +145,6 @@ def create_indexed_kernel(assignments: AssignmentOrAstNodeList, index_fields, fu loop_body = Block([]) loop_node = LoopOverCoordinate(loop_body, coordinate_to_loop_over=0, start=0, stop=index_fields[0].shape[0]) implement_interpolations(loop_node) for assignment in assignments: loop_body.append(assignment) ... ...
 ... ... @@ -105,9 +105,8 @@ class Discretization2ndOrder: return self._discretize_advection(e) elif isinstance(e, Diff): arg, *indices = diff_args(e) from pystencils.interpolation_astnodes import InterpolatorAccess if not isinstance(arg, (Field.Access, InterpolatorAccess)): if not isinstance(arg, Field.Access): raise ValueError("Only derivatives with field or field accesses as arguments can be discretized") return self.spatial_stencil(indices, self.dx, arg) else: ... ...
 ... ... @@ -4,9 +4,7 @@ from pystencils.backends.cbackend import get_headers from pystencils.backends.cuda_backend import generate_cuda from pystencils.data_types import StructType from pystencils.field import FieldType from pystencils.gpucuda.texture_utils import ndarray_to_tex from pystencils.include import get_pycuda_include_path, get_pystencils_include_path from pystencils.interpolation_astnodes import InterpolatorAccess, TextureCachedField from pystencils.kernel_wrapper import KernelWrapper from pystencils.kernelparameters import FieldPointerSymbol ... ... @@ -47,29 +45,11 @@ def make_python_function(kernel_function_node, argument_dict=None, custom_backen code += "#define FUNC_PREFIX __global__\n" code += "#define RESTRICT __restrict__\n\n" code += str(generate_cuda(kernel_function_node, custom_backend=custom_backend)) textures = set(d.interpolator for d in kernel_function_node.atoms( InterpolatorAccess) if isinstance(d.interpolator, TextureCachedField)) nvcc_options = ["-w", "-std=c++11", "-Wno-deprecated-gpu-targets"] if USE_FAST_MATH: nvcc_options.append("-use_fast_math") # Code for CubicInterpolationCUDA from pystencils.interpolation_astnodes import InterpolationMode from os.path import join, dirname, isdir if any(t.interpolation_mode == InterpolationMode.CUBIC_SPLINE for t in textures): assert isdir(join(dirname(__file__), ("CubicInterpolationCUDA", "code")), "Submodule CubicInterpolationCUDA does not exist.\n" + "Clone https://github.com/theHamsta/CubicInterpolationCUDA into pystencils.gpucuda") nvcc_options += ["-I" + join(dirname(__file__), "CubicInterpolationCUDA", "code")] nvcc_options += ["-I" + join(dirname(__file__), "CubicInterpolationCUDA", "code", "internal")] needed_dims = set(t.field.spatial_dimensions for t in textures if t.interpolation_mode == InterpolationMode.CUBIC_SPLINE) for i in needed_dims: code = 'extern "C++" {\n#include "cubicTex%iD.cu"\n}\n' % i + code mod = SourceModule(code, options=nvcc_options, include_dirs=[ get_pystencils_include_path(), get_pycuda_include_path()]) func = mod.get_function(kernel_function_node.function_name) ... ... @@ -95,12 +75,6 @@ def make_python_function(kernel_function_node, argument_dict=None, custom_backen block_and_thread_numbers['block'] = tuple(int(i) for i in block_and_thread_numbers['block']) block_and_thread_numbers['grid'] = tuple(int(i) for i in block_and_thread_numbers['grid']) # TODO: use texture objects: # https://devblogs.nvidia.com/cuda-pro-tip-kepler-texture-objects-improve-performance-and-flexibility/ for tex in textures: tex_ref = mod.get_texref(str(tex)) ndarray_to_tex(tex_ref, full_arguments[tex.field.name], tex.address_mode, tex.filter_mode, tex.use_normalized_coordinates, tex.read_as_integer) args = _build_numpy_argument_list(parameters, full_arguments) cache[key] = (args, block_and_thread_numbers) cache_values.append(kwargs) # keep objects alive such that ids remain unique ... ...
 ... ... @@ -7,8 +7,8 @@ from pystencils.enums import Target, Backend from pystencils.gpucuda.cudajit import make_python_function from pystencils.gpucuda.indexing import BlockIndexing from pystencils.transformations import ( add_types, get_base_buffer_index, get_common_shape, implement_interpolations, parse_base_pointer_info, resolve_buffer_accesses, resolve_field_accesses, unify_shape_symbols) add_types, get_base_buffer_index, get_common_shape, parse_base_pointer_info, resolve_buffer_accesses, resolve_field_accesses, unify_shape_symbols) def create_cuda_kernel(assignments, ... ... @@ -17,8 +17,7 @@ def create_cuda_kernel(assignments, indexing_creator=BlockIndexing, iteration_slice=None, ghost_layers=None, skip_independence_check=False, use_textures_for_interpolation=True): skip_independence_check=False): assert assignments, "Assignments must not be empty!" fields_read, fields_written, assignments = add_types(assignments, type_info, not skip_independence_check) all_fields = fields_read.union(fields_written) ... ... @@ -74,8 +73,6 @@ def create_cuda_kernel(assignments, assignments=assignments) ast.global_variables.update(indexing.index_variables) implement_interpolations(ast, implement_by_texture_accesses=use_textures_for_interpolation) base_pointer_spec = [['spatialInner0']] base_pointer_info = {f.name: parse_base_pointer_info(base_pointer_spec, [2, 1, 0], f.spatial_dimensions, f.index_dimensions) ... ... @@ -110,8 +107,7 @@ def created_indexed_cuda_kernel(assignments, function_name="kernel", type_info=None, coordinate_names=('x', 'y', 'z'), indexing_creator=BlockIndexing, use_textures_for_interpolation=True): indexing_creator=BlockIndexing): fields_read, fields_written, assignments = add_types(assignments, type_info, check_independence_condition=False) all_fields = fields_read.union(fields_written) read_only_fields = set([f.name for f in fields_read - fields_written]) ... ... @@ -150,8 +146,6 @@ def created_indexed_cuda_kernel(assignments, None, function_name, assignments=assignments) ast.global_variables.update(indexing.index_variables) implement_interpolations(ast, implement_by_texture_accesses=use_textures_for_interpolation) coord_mapping = indexing.coordinates base_pointer_spec = [['spatialInner0']] base_pointer_info = {f.name: parse_base_pointer_info(base_pointer_spec, [2, 1, 0], ... ...
<
 # -*- coding: utf-8 -*- # # Copyright © 2019 Stephan Seitz # # Distributed under terms of the GPLv3 license. """ """ import hashlib import itertools from enum import Enum from typing import Set import sympy as sp