Skip to content
Permalink
Browse files

statistics_chains cleanup (#3404)

Description of changes:
 - Removed unused code from statistics_chains
 - Replaced globals by function parameters
  • Loading branch information
kodiakhq committed Jan 8, 2020
2 parents 75d7a32 + 75767d4 commit baa014fd700e8be050e15dc55e1aa26a988cb6ec
@@ -57,7 +57,6 @@
#include "pressure.hpp"
#include "rotation.hpp"
#include "statistics.hpp"
#include "statistics_chain.hpp"
#include "virtual_sites.hpp"

#include "electrostatics_magnetostatics/coulomb.hpp"
@@ -21,32 +21,10 @@
/** \file
Implementation of \ref statistics_chain.hpp "statistics_chain.hpp".
*/
#include "PartCfg.hpp"
#include "cells.hpp"
#include "communication.hpp"
#include "statistics.hpp"
#include <vector>
#include "statistics_chain.hpp"

/** Particles' initial positions (needed for g1(t), g2(t), g3(t)) */
/*@{*/
float *partCoord_g = nullptr, *partCM_g = nullptr;
int n_part_g = 0, n_chains_g = 0;
/*@}*/

/** data for a system consisting of chains. TBRS. */
/*@{*/
int chain_start = 0;
int chain_n_chains = 0;
int chain_length = 0;
/*@}*/

void update_mol_ids_setchains(const ParticleRange &particles) {
for (auto &p : particles) {
p.p.mol_id = floor((p.p.identity - chain_start) / (double)chain_length);
}
}

std::array<double, 4> calc_re(PartCfg &partCfg) {
std::array<double, 4> calc_re(PartCfg &partCfg, int chain_start,
int chain_n_chains, int chain_length) {
double dist = 0.0, dist2 = 0.0, dist4 = 0.0;
std::array<double, 4> re;

@@ -67,7 +45,8 @@ std::array<double, 4> calc_re(PartCfg &partCfg) {
return re;
}

std::array<double, 4> calc_rg(PartCfg &partCfg) {
std::array<double, 4> calc_rg(PartCfg &partCfg, int chain_start,
int chain_n_chains, int chain_length) {
int p;
double r_G = 0.0, r_G2 = 0.0, r_G4 = 0.0;
double tmp;
@@ -106,7 +85,8 @@ std::array<double, 4> calc_rg(PartCfg &partCfg) {
return rg;
}

std::array<double, 2> calc_rh(PartCfg &partCfg) {
std::array<double, 2> calc_rh(PartCfg &partCfg, int chain_start,
int chain_n_chains, int chain_length) {
double r_H = 0.0, r_H2 = 0.0, ri = 0.0, prefac, tmp;
std::array<double, 2> rh;

@@ -22,48 +22,55 @@
#define STATISTICS_CHAIN_H
/** \file
*
* This file contains the code for statistics on the data using the
* molecule information set with analyze set chains.
* This file contains the code for statistics on chains.
*/

#include "PartCfg.hpp"

/** \name Exported Variables */
/************************************************************/
/** Particles' initial positions (needed for g1(t), g2(t), g3(t)) */
/*@{*/
extern float *partCoord_g;
extern float *partCM_g;
extern int n_part_g;
extern int n_chains_g;
/*@}*/

/** data for a system consisting of chains. TBRS. */
/*@{*/
extern int chain_start;
extern int chain_n_chains;
extern int chain_length;
/*@}*/
#include <array>

/** \name Exported Functions */
/************************************************************/
/*@{*/

/** Calculate the end-to-end-distance.
* Chain information \ref chain_start etc. must be set!
/**
* @brief Calculate the end-to-end-distance.
*
* Calculates the average end-to-end-distance of a range
* of monodisperse polymers with continuous ids.
*
* @param chain_start The id of the first monomer of the first chain.
* @param chain_n_chains Number of chains contained in the range.
* @param chain_length The length of every chain.
*/
std::array<double, 4> calc_re(PartCfg &);
std::array<double, 4> calc_re(PartCfg &partCfg, int chain_start,
int chain_n_chains, int chain_length);

/** Calculate the radius of gyration.
* Chain information \ref chain_start etc. must be set!
/**
* @brief Calculate the radius of gyration.
*
* Calculates the average radius of gyration of a range
* of monodisperse polymers with continuous ids.
*
* @param chain_start The id of the first monomer of the first chain.
* @param chain_n_chains Number of chains contained in the range.
* @param chain_length The length of every chain.
*/
std::array<double, 4> calc_rg(PartCfg &);
std::array<double, 4> calc_rg(PartCfg &, int chain_start, int chain_n_chains,
int chain_length);

/** Calculate the hydrodynamic radius (ref. Kirkwood-Zimm theory).
* Chain information \ref chain_start etc. must be set!
/**
* @brief Calculate the hydrodynamic radius (ref. Kirkwood-Zimm theory).
*
* Calculates the average hydrodynamic radius of a range
* of monodisperse polymers with continuous ids.
*
* @param chain_start The id of the first monomer of the first chain.
* @param chain_n_chains Number of chains contained in the range.
* @param chain_length The length of every chain.
*/
std::array<double, 2> calc_rh(PartCfg &);

std::array<double, 2> calc_rh(PartCfg &, int chain_start, int chain_n_chains,
int chain_length);
/*@}*/

#endif
@@ -103,12 +103,9 @@ cdef extern from "statistics.hpp":
double * dist)

cdef extern from "statistics_chain.hpp":
int chain_start
int chain_n_chains
int chain_length
array4 calc_re(PartCfg & )
array4 calc_rg(PartCfg & ) except +
array2 calc_rh(PartCfg & )
array4 calc_re(PartCfg &, int, int, int)
array4 calc_rg(PartCfg &, int, int, int) except +
array2 calc_rh(PartCfg &, int, int, int)

cdef extern from "pressure.hpp":
cdef Observable_stat total_pressure
@@ -755,7 +755,11 @@ class Analysis:
"""
self.check_topology(chain_start, number_of_chains, chain_length)
re = analyze.calc_re(analyze.partCfg())
re = analyze.calc_re(
analyze.partCfg(),
chain_start,
number_of_chains,
chain_length)
return np.array([re[0], re[1], re[2], re[3]])

def calc_rg(self, chain_start=None, number_of_chains=None,
@@ -787,7 +791,11 @@ class Analysis:
"""
self.check_topology(chain_start, number_of_chains, chain_length)
rg = analyze.calc_rg(analyze.partCfg())
rg = analyze.calc_rg(
analyze.partCfg(),
chain_start,
number_of_chains,
chain_length)
return np.array([rg[0], rg[1], rg[2], rg[3]])

def calc_rh(self, chain_start=None, number_of_chains=None,
@@ -818,7 +826,11 @@ class Analysis:
"""

self.check_topology(chain_start, number_of_chains, chain_length)
rh = analyze.calc_rh(analyze.partCfg())
rh = analyze.calc_rh(
analyze.partCfg(),
chain_start,
number_of_chains,
chain_length)
return np.array([rh[0], rh[1]])

def check_topology(self, chain_start=None, number_of_chains=None,
@@ -838,9 +850,6 @@ class Analysis:
'n_chains={2:.0f}, chain_length={3:.0f}\n'
'please provide a contiguous range of particle ids'.format(
i, chain_start, number_of_chains, chain_length))
analyze.chain_start = chain_start
analyze.chain_n_chains = number_of_chains
analyze.chain_length = chain_length

#
# Structure factor

0 comments on commit baa014f

Please sign in to comment.
You can’t perform that action at this time.