-
Notifications
You must be signed in to change notification settings - Fork 31
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add a 'fast'-mode, surpassing robustness code (#59)
In normal mode: WaterOilGas construction and SWOF+SGOF: 66 ms In fast mode: 36 ms
- Loading branch information
Showing
5 changed files
with
175 additions
and
51 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
"""Example code for benchmarking of the "fast" feature""" | ||
import timeit | ||
|
||
from pyscal import WaterOilGas | ||
|
||
|
||
def benchme(fast=False, doprint=False): | ||
"""Test function for benchmarking the "fast"-feature | ||
Pipe the following code snip into "ipython" on the shell: | ||
> echo "import benchme | ||
%timeit benchme.benchme() | ||
%timeit benchme.benchme(fast=True) | ||
" | ipython | ||
or run this module directly | ||
""" | ||
wog = WaterOilGas(swl=0.1, h=0.1, fast=fast) | ||
wog.wateroil.add_corey_oil(now=3, kroend=0.9) | ||
wog.wateroil.add_corey_water(nw=2, krwend=0.2) | ||
wog.gasoil.add_corey_oil() | ||
wog.gasoil.add_corey_gas() | ||
if not doprint: | ||
len(wog.SWOF()) | ||
len(wog.SGOF()) | ||
else: | ||
print(wog.SWOF()) | ||
print(wog.SGOF()) | ||
|
||
|
||
if __name__ == "__main__": | ||
print("Running in robust and slow mode:") | ||
print( | ||
timeit.timeit( | ||
stmt="benchme(fast=False)", setup="from benchme import benchme", number=100 | ||
) | ||
) | ||
print("Running in fast mode:") | ||
print( | ||
timeit.timeit( | ||
stmt="benchme(fast=True)", setup="from benchme import benchme", number=100 | ||
) | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters