Skip to content

Commit

Permalink
Fix a bug related to the python bindings of the analysis backend
Browse files Browse the repository at this point in the history
Also add a test to catch these problems early
  • Loading branch information
lorenzo-rovigatti committed Aug 19, 2022
1 parent 59ec940 commit 719836c
Show file tree
Hide file tree
Showing 7 changed files with 240 additions and 3 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,8 @@ test/**/last_conf.dat
test/**/*log.dat
test/**/trajectory.dat
test/**/time.dat
test/OXPY/first_nucleotide.dat
test/OXPY/last_nucleotide.dat

**/*pyc

Expand Down
4 changes: 2 additions & 2 deletions src/Backends/AnalysisBackend.h
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,8 @@ class AnalysisBackend: public SimBackend {

const FlattenedConfigInfo &flattened_conf();

ConfigInfo *config_info() {
return _config_info;
std::shared_ptr<ConfigInfo> config_info() {
return CONFIG_INFO;
}

llint get_conf_step() {
Expand Down
10 changes: 10 additions & 0 deletions test/OXPY/first_nucleotide_correct.dat
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
[-11.78911323 43.40048831 1.57645506]
[-14.14325234 40.56472505 2.0471197 ]
[-18.32734558 37.03027119 2.42922245]
[-23.77341355 35.3688551 1.82196622]
[-30.6031531 34.80713034 4.54497927]
[-34.02963687 36.94788357 9.20757146]
[-38.71207711 36.98956237 6.66388904]
[-37.41612362 38.95930485 5.18552101]
[-35.66393047 38.5800238 2.98663143]
[-38.16168017 34.77034427 5.37125748]
24 changes: 24 additions & 0 deletions test/OXPY/input_analysis
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
backend = CPU

steps = 1e6
newtonian_steps = 103
diff_coeff = 2.50
#pt = 0.1
thermostat = john

T = 20C
dt = 0.005
verlet_skin = 0.05

topology = dsdna8.top
conf_file = non_existing_conf.dat
trajectory_file = trajectory_analysis.dat
refresh_vel = true
log_file = log.dat
no_stdout_energy = true
restart_step_counter = true
energy_file = energy.dat
print_conf_interval = 1e5
print_energy_every = 1e3
time_scale = linear
external_forces = false
1 change: 1 addition & 0 deletions test/OXPY/oxpy_compare
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
DiffFiles::last_nucleotide_correct.dat::last_nucleotide.dat
DiffFiles::first_nucleotide_correct.dat::first_nucleotide.dat
12 changes: 11 additions & 1 deletion test/OXPY/oxpy_input.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,4 +26,14 @@ def get_output_string(self, curr_step):
# run 1k steps
manager.run(1000)


with oxpy.Context():
inp = oxpy.InputFile()
inp.init_from_filename("input_analysis")
# this object will make it possible to access the trajectory data
backend = oxpy.analysis.AnalysisBackend(inp)

with open("first_nucleotide.dat", "w") as f:
# loop over all the configurations stored in the trajectory file
while backend.read_next_configuration():
# print the position of the first nucleotide
print(backend.config_info().particles()[0].pos, file=f)
190 changes: 190 additions & 0 deletions test/OXPY/trajectory_analysis.dat

Large diffs are not rendered by default.

0 comments on commit 719836c

Please sign in to comment.