New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Initial commit for the Black Scholes devito example #1288
Conversation
Check out this pull request on Review Jupyter notebook visual diffs & provide feedback on notebooks. Powered by ReviewNB |
Codecov Report
@@ Coverage Diff @@
## master #1288 +/- ##
===========================================
- Coverage 86.64% 60.85% -25.80%
===========================================
Files 182 147 -35
Lines 26153 17140 -9013
Branches 3598 3054 -544
===========================================
- Hits 22661 10431 -12230
- Misses 3064 6167 +3103
- Partials 428 542 +114
Continue to review full report at Codecov.
|
@rawsh Thanks for this work and contribution. I'll take a good look through everything early next week. |
from a quick glance this looks awesome. Thanks a lot for this! |
This looks super cool overall, thanks a lot for contributing it to the examples. I left a few minor comments but great work. |
@@ -0,0 +1,550 @@ | |||
{ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
for i in range(shape[0]):
v.data[0, i] = max((smin + ds0 * i) - K, 0)
This can be done in one line right?
Reply via ReviewNB
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I added another operator for the example without a boundary condition which added a line to the for loop so I left it how it was
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you very much for this contribution Robert. I think the notebook is in a very good shape already. A few minor fixes may be needed, but overall great work. Congrats!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice work!
I still think you need a little more exposition for the boundary conditions, as that is the heart of the success here. I also think you might consider adding an example of what happens when there is no boundary condition. so my suggestions:
- set up two operators, one without the BC and one with
- run both ops and contrast the results
- add more exposition for the BC, maybe some ASCII art as below, with comments like "x in the interior (s < smax) and determed by the PDE", "o in the boundary (s >= smax) and determined by the BC using a Eq" ...
ASCII ART
| o v(t,smax+1)
| /
|/
o v(t,smax)
/|
/ |
v(t,smax-1) X |
/ | BC: constant slope for v when s >= smax
/ | for 4th order derivative, need 2 points
v(t,smax-2) X | slope = v(t,smax-1) - v(t,smax-2)
/ | v(t,smax) = v(t,smax-1) + slope
/ | v(t,smax+1) = v(t,smax) + slope
v(t,smax-2) X |
|
interior | boundary
(s < smax) smax (s >= smax)
Maybe you should also highlight how devito is stupid fast (your words) compared to the other solution. also ... needs units.
|
need to wrap the ASCII in three single quotes on blank lines both ends, per markdown code segment. |
love the second example. suggest instead of "plateau", "fall incorrectly towards zero". |
you may also wanna update the README here: https://github.com/devitocodes/devito/tree/master/examples#how-to-navigate-this-directory with info about this new "finance" subdirectory |
"smin = 70\n", | ||
"smax = 130\n", | ||
"\n", | ||
"# If you want to try some different problems, uncomment these lines\n", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would it be possible to add a short description/explanation re. the various choices of constants?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Robert you might add a link to the various papers we looked at to reproduce results.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added an explanation. I added the papers I looked at that weren't behind paywalls (the 3 point approximation one I showed you is on research gate and I think the UNL math one is a better example anyway)
Very nice notebook, thanks for the contribution. Some nitpicking above. |
Thank you for the comments! It was a fun notebook to work on.
|
OK, I think this is ready, but we need to add it to our Continuous Integration framework. This means two small things:
@jkwashbourne I think you're already familiar with this |
I've got a small notebook demonstrating using Devito to solve a PDE with nonzero boundary conditions, please take a look and let me know what you think. Thanks