Skip to content

Commit db4e568

Browse files
authored
Merge pull request #4 from MikeHeiber/development
Development Update 3 to be included with v4.0-alpha.1
2 parents 8654326 + 71b020e commit db4e568

File tree

7 files changed

+388
-174
lines changed

7 files changed

+388
-174
lines changed

Morphology.cpp

Lines changed: 235 additions & 133 deletions
Large diffs are not rendered by default.

Morphology.h

Lines changed: 20 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,15 @@ struct NeighborInfo{
3636
char total3;
3737
};
3838

39+
struct CorrelationCalcParams {
40+
int N_sampling_max;
41+
bool Enable_mix_frac_method;
42+
bool Enable_e_method;
43+
bool Enable_extended_correlation_calc;
44+
int Correlation_cutoff_distance;
45+
};
46+
3947
struct TomogramImportParams {
40-
// Tomogram Import Options
4148
bool Enable_cutoff_analysis;
4249
int Mixed_greyscale_width;
4350
double Mixed_conc;
@@ -54,10 +61,10 @@ class Morphology {
5461
Morphology(const Lattice& input_lattice, const int id);
5562
virtual ~Morphology();
5663
bool calculateAnisotropies(const int N_sampling_max);
57-
void calculateCorrelationDistances(const bool enable_extended_calc, const int N_sampling_max);
64+
void calculateCorrelationDistances(const CorrelationCalcParams& parameters);
65+
void calculateDepthDependentData(const CorrelationCalcParams& correlation_params);
5866
double calculateInterfacialAreaVolumeRatio() const;
5967
bool calculateInterfacialDistance();
60-
//bool calculateInterfacialDistanceOld();
6168
double calculateInterfacialVolumeFraction() const;
6269
void calculateMixFractions();
6370
bool calculateTortuosity(const bool enable_reduced_memory);
@@ -68,6 +75,8 @@ class Morphology {
6875
void executeMixing(const double width, const double interfacial_conc);
6976
void executeSmoothing(const double smoothing_threshold, const int rescale_factor);
7077
std::vector<double> getCorrelationData(const char site_type) const;
78+
std::vector<double> getDepthCompositionData(const char site_type) const;
79+
std::vector<double> getDepthDomainSizeData(const char site_type) const;
7180
double getDomainSize(const char site_type) const;
7281
double getDomainAnisotropy(const char site_type) const;
7382
int getHeight() const;
@@ -108,7 +117,7 @@ class Morphology {
108117
};
109118
// properties
110119
int ID;
111-
std::vector<double> Mix_fractions; // Fraction of each component to total
120+
std::vector<double> Mix_fractions; // Volume fraction of each component to total
112121
bool Enable_third_neighbor_interaction;
113122
Lattice lattice;
114123
std::vector<char> Site_types;
@@ -117,13 +126,13 @@ class Morphology {
117126
std::vector<std::vector<float>> Tortuosity_data;
118127
std::vector<std::vector<double>> InterfacialHistogram_data;
119128
std::vector<std::vector<double>> TortuosityHistogram_data;
120-
std::vector<bool> Domain_size_updated;
129+
std::vector<std::vector<double>> Depth_composition_data;
130+
std::vector<std::vector<double>> Depth_domain_size_data;
121131
std::vector<bool> Domain_anisotropy_updated;
122-
std::vector<double> Domain_size;
123-
std::vector<double> Domain_anisotropy;
132+
std::vector<double> Domain_sizes;
133+
std::vector<double> Domain_anisotropies;
124134
std::vector<int> Island_volume;
125135
std::vector<long int> Interfacial_sites;
126-
std::vector<std::vector<long int>> Correlation_sites_data;
127136
std::vector<NeighborCounts> Neighbor_counts;
128137
std::vector<NeighborInfo> Neighbor_info;
129138
NeighborCounts Temp_counts1;
@@ -132,8 +141,8 @@ class Morphology {
132141
// functions
133142
void addSiteType(const char site_type);
134143
double calculateAdditionalEnergyChange(const long int site_index_main, const long int site_index_neighbor,const int growth_direction,const double additional_interaction) const;
135-
bool calculateAnisotropy(const char site_type,const int cutoff_distance,const int N_sampling_max);
136-
bool calculateCorrelationDistance(const char site_type, const int cutoff_distance, const bool enable_extended_calc, const int N_sampling_max);
144+
bool calculateAnisotropy(const std::vector<long int>& correlation_sites, const char site_type,const int cutoff_distance);
145+
double calculateCorrelationDistance(const std::vector<long int>& correlation_sites, std::vector<double>& correlation_data, const char site_type, const int cutoff_distance, const CorrelationCalcParams& params);
137146
double calculateDissimilarFraction(const Coords& coords, const int rescale_factor) const;
138147
double calculateEnergyChangeSimple(const long int site_index1, const long int site_index2, const double interaction_energy1, const double interaction_energy2);
139148
double calculateEnergyChange(const Coords& coords1, const Coords& coords2,const double interaction_energy1,const double interaction_energy2) const;
@@ -142,6 +151,7 @@ class Morphology {
142151
bool calculatePathDistances_ReducedMemory(std::vector<float>& path_distances);
143152
void createNode(Node& node,const Coords& coords);
144153
void getSiteSampling(std::vector<long int>& sites, const char site_type, const int N_sites);
154+
void getSiteSamplingZ(std::vector<long int>& sites, const char site_type, const int N_sites, const int z);
145155
int getSiteTypeIndex(const char site_type) const;
146156
void initializeNeighborInfo();
147157
bool isNearInterface(const Coords& coords, const double distance) const;

Utils.cpp

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,8 @@ namespace Utils {
2020

2121
vector<pair<double, double>> calculateProbabilityHist(const vector<double>& data, int num_bins) {
2222
// Determine data range
23-
double min_val, max_val;
23+
double min_val = 0;
24+
double max_val = 0;
2425
auto min_it = min_element(data.begin(), data.end());
2526
if (min_it != data.end()) {
2627
min_val = *min_it;
@@ -46,7 +47,8 @@ namespace Utils {
4647

4748
vector<pair<double, double>> calculateProbabilityHist(const vector<double>& data, double bin_size) {
4849
// Determine data range
49-
double min_val, max_val;
50+
double min_val = 0;
51+
double max_val = 0;
5052
auto min_it = min_element(data.begin(), data.end());
5153
if (min_it != data.end()) {
5254
min_val = *min_it;
@@ -73,7 +75,7 @@ namespace Utils {
7375

7476
vector<pair<double, double>> calculateProbabilityHist(const vector<double>& data, const double bin_size, const int num_bins) {
7577
// Determine number of bins
76-
double min_val;
78+
double min_val = 0;
7779
auto min_it = min_element(data.begin(), data.end());
7880
if (min_it != data.end()) {
7981
min_val = *min_it;

Utils.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
#include <iostream>
1313
#include <memory>
1414
#include <mpi.h>
15+
#include <fstream>
1516
#include <random>
1617
#include <set>
1718
#include <string>
@@ -187,8 +188,7 @@ namespace Utils {
187188

188189
template<typename T>
189190
T array_median(const T data[], const int array_size) {
190-
T element;
191-
std::vector<T> data_vect(array_size, element);
191+
std::vector<T> data_vect(array_size);
192192
for (int i = 0; i<array_size; i++) {
193193
data_vect[i] = data[i];
194194
}
@@ -244,7 +244,7 @@ namespace Utils {
244244
//! \param filename is the input file name.
245245
template<typename T>
246246
void outputVectorToFile(std::vector<T>& vec, std::string filename) {
247-
ofstream outfile;
247+
std::ofstream outfile;
248248
outfile.open(filename);
249249
for (int i = 0; i < (int)vec.size(); i++) {
250250
outfile << vec[i] << "\n";
@@ -258,7 +258,7 @@ namespace Utils {
258258
//! \param filename is the input file name.
259259
template<typename T>
260260
void outputVectorToFile(std::vector<std::pair<T,T>>& vec, std::string filename) {
261-
ofstream outfile;
261+
std::ofstream outfile;
262262
outfile.open(filename);
263263
for (int i = 0; i < (int)vec.size(); i++) {
264264
outfile << vec[i].first << "," << vec[i].second << "\n";

0 commit comments

Comments
 (0)