Skip to content
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

tune_skin: add adjust_max_skin feature. #3011

Merged
merged 10 commits into from
Jul 26, 2019
Merged

Conversation

pkreissl
Copy link
Contributor

Fixes #2961

Description of changes:

  • Add adjust_max_skin parameter to tune_skin() method, which adds the option to automatically adjust max_skin if the passed value is larger than permitted (0.5 * local box length - short range cutoff)
  • Rename core variables to match interface.

As a test you can run the following script adjusted from @RudolfWeeber s minimal script in issue #2961

import espressomd
s = espressomd.System(box_l=[1,1,1])
s.time_step = 0.01
s.non_bonded_inter[0,0].lennard_jones.set_params(epsilon=1,sigma=0.2,cutoff=0.3,shift="auto")
print("=> Tune with adjustment:")
s.cell_system.tune_skin(min_skin=0.1,max_skin=0.6,tol=0.05, int_steps=3, adjust_max_skin=True)
print(s.cell_system.skin)
print("=> and fail without:")
s.cell_system.tune_skin(min_skin=0.1,max_skin=0.6,tol=0.05, int_steps=3)

resulting in the following output:

$ ./pypresso tune_skin.py
=> Tune with adjustment:
0.17500000000000002
=> and fail without:
There were unhandled errors.
ERROR: number of cells 1 is smaller than minimum 8 (interaction range too large or min_num_cells too large)

@RudolfWeeber
Copy link
Contributor

the "unhandled error" indicates that at the end of the tune_skin function in python utils.handle_errors() needs to be called. That would then raise an exception

Can you please add a test based on the script in the comment.
You can check for the exception via with self.assertRaises()

Please set adjust_max_skin=True in maintainer/benchmarks/p3m.py. That may solve #2924.

@pkreissl
Copy link
Contributor Author

Now, with proper error handling

$ ./pypresso tune_skin.py
=> Tune with adjustment:
0.17500000000000002
=> and fail without:
ERROR: number of cells 1 is smaller than minimum 8 (interaction range too large or min_num_cells too large)
Traceback (most recent call last):
  File "tune_skin.py", line 9, in <module>
    s.cell_system.tune_skin(min_skin=0.1,max_skin=0.6,tol=0.05, int_steps=3)
  File "cellsystem.pyx", line 310, in espressomd.cellsystem.CellSystem.tune_skin
  File "utils.pyx", line 265, in espressomd.utils.handle_errors
Exception: Error during tune_skin: ERROR: number of cells 1 is smaller than minimum 8 (interaction range too large or min_num_cells too large)

@codecov
Copy link

codecov bot commented Jul 25, 2019

Codecov Report

Merging #3011 into python will decrease coverage by <1%.
The diff coverage is 100%.

Impacted file tree graph

@@          Coverage Diff           @@
##           python   #3011   +/-   ##
======================================
- Coverage      82%     82%   -1%     
======================================
  Files         526     526           
  Lines       26754   26758    +4     
======================================
- Hits        22041   22025   -16     
- Misses       4713    4733   +20
Impacted Files Coverage Δ
src/core/tuning.cpp 95% <100%> (ø) ⬆️
src/core/domain_decomposition.cpp 94% <0%> (-4%) ⬇️
src/core/layered.cpp 77% <0%> (-1%) ⬇️
src/core/collision.cpp 79% <0%> (-1%) ⬇️
src/core/electrostatics_magnetostatics/p3m.cpp 85% <0%> (-1%) ⬇️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 96bd96b...ae19829. Read the comment docs.

@@ -77,6 +77,7 @@ foreach(TEST_COMBINATION lb.cpu-p3m.cpu-lj;lb.gpu-p3m.cpu-lj;ek.gpu)
endforeach(TEST_BINARY)
endforeach(TEST_COMBINATION)
python_test(FILE cellsystem.py MAX_NUM_PROC 4)
python_test(FILE tune_skin.py MAX_NUM_PROC 1)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@RudolfWeeber how many threads should we use here?

Copy link
Contributor

@RudolfWeeber RudolfWeeber left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

bors r+

@bors
Copy link
Contributor

bors bot commented Jul 26, 2019

Merge conflict

@jngrad
Copy link
Member

jngrad commented Jul 26, 2019

bors r=RudolfWeeber

bors bot added a commit that referenced this pull request Jul 26, 2019
3011: tune_skin: add adjust_max_skin feature. r=RudolfWeeber a=pkreissl

Fixes #2961

Description of changes:
 - Add `adjust_max_skin` parameter to `tune_skin()` method, which adds the option to automatically adjust `max_skin` if the passed value is larger than permitted (0.5 * local box length - short range cutoff)
 - Rename core variables to match interface.

As a test you can run the following script adjusted from @RudolfWeeber s minimal script in issue #2961
```python
import espressomd
s = espressomd.System(box_l=[1,1,1])
s.time_step = 0.01
s.non_bonded_inter[0,0].lennard_jones.set_params(epsilon=1,sigma=0.2,cutoff=0.3,shift="auto")
print("=> Tune with adjustment:")
s.cell_system.tune_skin(min_skin=0.1,max_skin=0.6,tol=0.05, int_steps=3, adjust_max_skin=True)
print(s.cell_system.skin)
print("=> and fail without:")
s.cell_system.tune_skin(min_skin=0.1,max_skin=0.6,tol=0.05, int_steps=3)
``` 
resulting in the following output:
```
$ ./pypresso tune_skin.py
=> Tune with adjustment:
0.17500000000000002
=> and fail without:
There were unhandled errors.
ERROR: number of cells 1 is smaller than minimum 8 (interaction range too large or min_num_cells too large)
```



Co-authored-by: Patrick Kreissl <patrick.kreissl@pa-le.de>
Co-authored-by: Jean-Noël Grad <jgrad@icp.uni-stuttgart.de>
@bors
Copy link
Contributor

bors bot commented Jul 26, 2019

Timed out

@jngrad
Copy link
Member

jngrad commented Jul 26, 2019

bors retry

bors bot added a commit that referenced this pull request Jul 26, 2019
3011: tune_skin: add adjust_max_skin feature. r=RudolfWeeber a=pkreissl

Fixes #2961

Description of changes:
 - Add `adjust_max_skin` parameter to `tune_skin()` method, which adds the option to automatically adjust `max_skin` if the passed value is larger than permitted (0.5 * local box length - short range cutoff)
 - Rename core variables to match interface.

As a test you can run the following script adjusted from @RudolfWeeber s minimal script in issue #2961
```python
import espressomd
s = espressomd.System(box_l=[1,1,1])
s.time_step = 0.01
s.non_bonded_inter[0,0].lennard_jones.set_params(epsilon=1,sigma=0.2,cutoff=0.3,shift="auto")
print("=> Tune with adjustment:")
s.cell_system.tune_skin(min_skin=0.1,max_skin=0.6,tol=0.05, int_steps=3, adjust_max_skin=True)
print(s.cell_system.skin)
print("=> and fail without:")
s.cell_system.tune_skin(min_skin=0.1,max_skin=0.6,tol=0.05, int_steps=3)
``` 
resulting in the following output:
```
$ ./pypresso tune_skin.py
=> Tune with adjustment:
0.17500000000000002
=> and fail without:
There were unhandled errors.
ERROR: number of cells 1 is smaller than minimum 8 (interaction range too large or min_num_cells too large)
```



Co-authored-by: Patrick Kreissl <patrick.kreissl@pa-le.de>
Co-authored-by: Jean-Noël Grad <jgrad@icp.uni-stuttgart.de>
@bors
Copy link
Contributor

bors bot commented Jul 26, 2019

Build succeeded

@bors bors bot merged commit ae19829 into espressomd:python Jul 26, 2019
@pkreissl pkreissl deleted the tune_skin branch July 29, 2019 12:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

s.cell_system.tune_skin() ignores short range cutoff
3 participants