Skip to content

Commit

Permalink
add an option to output hdf5 more
Browse files Browse the repository at this point in the history
frequently than output protobuf file +
little restructuring of Statistics for better
 readability by fragmenting update()
(update() still way too long)
  • Loading branch information
barakr committed Nov 1, 2023
1 parent 21f1dfa commit c5bbfb2
Show file tree
Hide file tree
Showing 6 changed files with 178 additions and 131 deletions.
8 changes: 5 additions & 3 deletions data/npctransport.proto
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,8 @@ message Configuration {
optional int32 is_multiple_hdf5s=43; // if true, output new hdf5 every output_statistics_interval_ns,
// then add a numeric suffix to hdf5 for each dump
// e.g. output_1.pb.hdf5, output_2.pb.hdf5, etc. Default is only once in the end.
// n=43
optional int32 full_output_statistics_interval_factor=44 [default=1]; // if >1, output full output file every output_statistics_interval_ns*full_output_interval_factor
// n=44
}

// if you add any parameters you must update automatic_parameters.cpp
Expand Down Expand Up @@ -269,7 +270,7 @@ message Assignment {
optional int32 output_statistics_interval_frames=41 [default=100000]; // update interval of statistics file (including order params) in frames
optional FloatAssignment temperature_k=42; // simulation temperature
optional double output_npctransport_version=43; // a version number for npctransport by which to interpret output file that contains this assignment
optional int32 is_xyz_hist_stats=44 [default=1]; // whether to use an xyz histogram instead of zr histogram (= whether to project x and y to sqrt(x^2+y^2)
optional int32 is_xyz_hist_stats=44 [default=1]; // whether to use an xyz histogram instead of zr histogram (= whether to project x and y to sqrt(x^2+y^2); if so output ot HDF5 file
optional double xyz_stats_crop_factor=49 [default=0.5]; // percentage of box to crop from each axis for xyz histogram (symmetrically).
optional double xyz_stats_voxel_size_a=50 [default=10.0]; // size of voxel in A for xyz histogram
optional double xyz_stats_max_box_size_a=51 [default=2000.0]; // maximal size of box for xyz stats
Expand All @@ -280,7 +281,8 @@ message Assignment {
optional int32 is_multiple_hdf5s=52; // if true, output new hdf5 every output_statistics_interval_ns,
// then add a numeric suffix to hdf5 for each dump
// e.g. output_1.pb.hdf5, output_2.pb.hdf5, etc. Default is only once in the end.
// n=52
optional int32 full_output_statistics_interval_factor=53 [default=1]; // if >1, output full output file every output_statistics_interval_ns*full_output_interval_factor
// n=53
}

message Statistics {
Expand Down
4 changes: 4 additions & 0 deletions include/SimulationData.h
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ class IMPNPCTRANSPORTEXPORT SimulationData : public Object {
Parameter<double> statistics_fraction_;
Parameter<int> statistics_interval_frames_;
Parameter<int> output_statistics_interval_frames_;
Parameter<int> full_output_statistics_interval_factor_;
Parameter<int> is_multiple_hdf5s_;
Parameter<double> time_step_;
Parameter<double> time_step_wave_factor_;
Expand All @@ -90,6 +91,9 @@ class IMPNPCTRANSPORTEXPORT SimulationData : public Object {
int get_output_statistics_interval_frames() const
{ return output_statistics_interval_frames_; }

int get_full_output_statistics_interval_factor() const
{ return full_output_statistics_interval_factor_; }

// if true, hdf5s are generated every get_output_statistics_interval_frames() frames
bool get_is_multiple_hdf5s()
{
Expand Down
18 changes: 16 additions & 2 deletions include/Statistics.h
Original file line number Diff line number Diff line change
Expand Up @@ -228,6 +228,10 @@ class IMPNPCTRANSPORTEXPORT Statistics : public Object {
@note this method is not const cause it may invoke e.g., energy evaluation
though it does not substantially change anything in the state of the object
@note if configuration file full_output_statistics_interval_factor
is larger than 1, then full statistics are dumped every N calls
to update(), where N is the value of full_output_statistics_interval_factor,
and only the HDF5 file is updated at each call.
*/
void update(const IMP::internal::SimpleTimer &timer,
unsigned int nf_new = 1);
Expand Down Expand Up @@ -284,10 +288,18 @@ class IMPNPCTRANSPORTEXPORT Statistics : public Object {

//! updates pStats with all statistics related to fgs, averaged over
//! nf_new additional frames
//! @param zr_hist a grid on z / (x,y)-radial axis relevant only if not outputting xyz stats to hdf5
void update_fg_stats( ::npctransport_proto::Statistics* pStats,
unsigned int nf_new,
unsigned int zr_hist[4][3],
RMF::HDF5::File hdf5_file);
unsigned int zr_hist[4][3]);

//! updates pStats with all statistics related to floaters, averaged over
//! nf_new additional frames
//!
//! @return for historical reasons, returns a map of diffusion coefficients for each particle type
//! to be used in order params later on
std::map<IMP::core::ParticleType, double> update_floater_stats( ::npctransport_proto::Statistics* pStats,
unsigned int nf_new);



Expand Down Expand Up @@ -335,6 +347,8 @@ class IMPNPCTRANSPORTEXPORT Statistics : public Object {
void fill_in_zr_hist(unsigned int zr_hist[4][3],
ParticlesTemp ps) const;

void update_hdf5_statistics(); // output HDF5 statistics


public:
IMP_OBJECT_METHODS(Statistics);
Expand Down
1 change: 1 addition & 0 deletions src/SimulationData.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,7 @@ void SimulationData::initialize(std::string prev_output_file,
GET_VALUE(range);
GET_VALUE(statistics_interval_frames);
GET_VALUE_DEF(output_statistics_interval_frames,10000);
GET_VALUE_DEF(full_output_statistics_interval_factor, 1);
GET_VALUE_DEF(is_multiple_hdf5s, false);
GET_ASSIGNMENT(statistics_fraction);
GET_VALUE(time_step);
Expand Down
Loading

0 comments on commit c5bbfb2

Please sign in to comment.