diff --git a/postprocessing/Makefile b/postprocessing/Makefile index e2937b6..69cb856 100644 --- a/postprocessing/Makefile +++ b/postprocessing/Makefile @@ -1,97 +1,97 @@ IDIR =./include CXX=g++ #CPPFLAGS=-g -I$(IDIR) -I/home/samarth/codes/voronoi/include -std=c++11 -O3 -w -Wall -CPPFLAGS=-g -I$(IDIR) -O3 -#CPPFLAGS=-I$(IDIR) -O3 +#CPPFLAGS=-g -I$(IDIR) -O3 +CPPFLAGS=-I$(IDIR) -O3 LDFLAGS=-O3 POSTFIX=-L/home/samarth/codes/voronoi/lib/ -lvoro++ SRC_DIR = ./src OBJ_DIR = ./obj SRC_FILES = $(wildcard $(SRC_DIR)/*.cpp) OBJ_FILES = $(patsubst $(SRC_DIR)/%.cpp,$(OBJ_DIR)/%.o,$(SRC_FILES)) BIN_SRC_DIR = ./bin_src BIN_DIR = ./bin all: unfold radius_of_gyration sq_vs_q pair_correlation percolation load_bearing_paths lr_iq lbp_brute_force percolation_invA chemical_distance lb_bonds_clusterwise_invA lbp_bfs #all: psd_test density_correlation: $(OBJ_FILES) | $(BIN_DIR) $(CXX) $(CPPFLAGS) -c -o density_correlation.o target/density_correlation.cpp $(CXX) $(LDFLAGS) -o $(BIN_DIR)/$@ $^ density_correlation.o unfold: $(OBJ_FILES) | $(BIN_DIR) $(CXX) $(CPPFLAGS) -c -o unfold.o target/unfold.cpp $(CXX) $(LDFLAGS) -o $(BIN_DIR)/$@ $^ unfold.o radius_of_gyration: $(OBJ_FILES) | $(BIN_DIR) $(CXX) $(CPPFLAGS) -c -o radius_of_gyration.o target/radius_of_gyration.cpp $(CXX) $(LDFLAGS) -o $(BIN_DIR)/$@ $^ radius_of_gyration.o sq_vs_q: $(OBJ_FILES) | $(BIN_DIR) $(CXX) $(CPPFLAGS) -c -o sq_vs_q.o target/sq_vs_q.cpp $(CXX) $(LDFLAGS) -o $(BIN_DIR)/$@ $^ sq_vs_q.o pair_correlation: $(OBJ_FILES) | $(BIN_DIR) $(CXX) $(CPPFLAGS) -c -o pair_correlation.o target/pair_correlation.cpp $(CXX) $(LDFLAGS) -o $(BIN_DIR)/$@ $^ pair_correlation.o psd_test: $(OBJ_FILES) | $(BIN_DIR) $(CXX) $(CPPFLAGS) -c -o psd_test.o target/psd_test.cpp $(CXX) $(LDFLAGS) -o $(BIN_DIR)/$@ $^ psd_test.o percolation: $(OBJ_FILES) | $(BIN_DIR) $(CXX) $(CPPFLAGS) -c -o percolation.o target/percolation.cpp $(CXX) $(LDFLAGS) -o $(BIN_DIR)/$@ $^ percolation.o load_bearing_paths: $(OBJ_FILES) | $(BIN_DIR) $(CXX) $(CPPFLAGS) -c -o load_bearing_paths.o target/load_bearing_paths.cpp $(CXX) $(LDFLAGS) -o $(BIN_DIR)/$@ $^ load_bearing_paths.o lbp_brute_force: $(OBJ_FILES) | $(BIN_DIR) $(CXX) $(CPPFLAGS) -c -o lbp_brute_force.o target/lbp_brute_force.cpp $(CXX) $(LDFLAGS) -o $(BIN_DIR)/$@ $^ lbp_brute_force.o percolation_invA: $(OBJ_FILES) | $(BIN_DIR) $(CXX) $(CPPFLAGS) -c -o percolation_invA.o target/percolation_invA.cpp $(CXX) $(LDFLAGS) -o $(BIN_DIR)/$@ $^ percolation_invA.o lb_bonds_invA: $(OBJ_FILES) | $(BIN_DIR) $(CXX) $(CPPFLAGS) -c -o lb_bonds_invA.o target/lb_bonds_invA.cpp $(CXX) $(LDFLAGS) -o $(BIN_DIR)/$@ $^ lb_bonds_invA.o lb_bonds_clusterwise_invA: $(OBJ_FILES) | $(BIN_DIR) $(CXX) $(CPPFLAGS) -c -o lb_bonds_clusterwise_invA.o target/lb_bonds_clusterwise_invA.cpp $(CXX) $(LDFLAGS) -o $(BIN_DIR)/$@ $^ lb_bonds_clusterwise_invA.o lb_bonds_via_cg: $(OBJ_FILES) | $(BIN_DIR) $(CXX) $(CPPFLAGS) -c -o lb_bonds_via_cg.o target/lb_bonds_via_cg.cpp $(CXX) $(LDFLAGS) -o $(BIN_DIR)/$@ $^ lb_bonds_via_cg.o chemical_distance: $(OBJ_FILES) | $(BIN_DIR) $(CXX) $(CPPFLAGS) -c -o chemical_distance.o target/chemical_distance.cpp $(CXX) $(LDFLAGS) -o $(BIN_DIR)/$@ $^ chemical_distance.o lr_iq: $(OBJ_FILES) | $(BIN_DIR) $(CXX) $(CPPFLAGS) -c -o lr_iq.o target/lr_iq.cpp $(CXX) $(LDFLAGS) -o $(BIN_DIR)/$@ $^ lr_iq.o lbp_bfs: $(OBJ_FILES) | $(BIN_DIR) $(CXX) $(CPPFLAGS) -c -o lbp_bfs.o target/lbp_bfs.cpp $(CXX) $(LDFLAGS) -o $(BIN_DIR)/$@ $^ lbp_bfs.o $(OBJ_DIR)/%.o: $(SRC_DIR)/%.cpp | $(OBJ_DIR) $(CXX) $(CPPFLAGS) -c -o $@ $< $(BIN_DIR): mkdir $(BIN_DIR) $(OBJ_DIR): mkdir $(OBJ_DIR) clean: rm *.o rm -rf $(BIN_DIR) rm -rf $(OBJ_DIR) diff --git a/scripts/setup_simulation_rsp_2d.py b/scripts/setup_simulation_rsp_2d.py new file mode 100755 index 0000000..551b1fa --- /dev/null +++ b/scripts/setup_simulation_rsp_2d.py @@ -0,0 +1,218 @@ +#!/usr/bin/env python3 +# -*- coding: utf-8 -*- +""" +Created on Fri Jun 4 13:56:09 2021 + +@author: samarth +""" + +import pandas as pd +import os +import sys +from pathlib import Path +from joblib import Parallel, delayed +from matplotlib import pyplot as plt +import numpy as np +from sklearn.linear_model import LinearRegression +from random import random, seed + + +def create_dirs(phi, N, seed_pct, dim): + + global D + + D = dim + + global params_dir + + phi_str = format(phi, '.8f') + + params_dir = './'+str(D)+'d/params/phi='+phi_str+'/seed_pct='+str(seed_pct)+'/L='+str(N)+'/' + path = Path(params_dir) + + try: + path.mkdir(parents=True, exist_ok=True) + except OSError: + pass + else: + pass + + + global results_dir + + results_dir = './'+str(D)+'d/results/phi='+phi_str+'/seed_pct='+str(seed_pct)+'/L='+str(N)+'/' + path = Path(results_dir) + + try: + path.mkdir(parents=True, exist_ok=True) + except OSError: + pass + else: + pass + + global config_files_dir + + config_files_dir = './'+str(D)+'d/config_files/phi='+phi_str+'/seed_pct='+str(seed_pct)+'/L='+str(N)+'/' + path = Path(config_files_dir) + + try: + path.mkdir(parents=True, exist_ok=True) + except OSError: + pass + else: + pass + +def run_simulation(phi, L, seed_pct, rng_seed): + + lattice=1 + + params_file = params_dir+'params_'+str(rng_seed)+'.csv' + + file = open(params_file, "w") + + file.write("system=random_site_percolation\n") + file.write("lattice="+str(lattice)+"\n") + file.write("D="+str(D)+"\n") + file.write("phi="+str(phi)+"\n") + file.write("seed_pct="+str(seed_pct)+"\n") + + for axis in range(D): + file.write("x"+str(axis)+"_bc=periodic\n") + + for axis in range(D): + file.write("x"+str(axis)+"_L="+str(L)+"\n") + + file.write("rng_seed="+str(rng_seed)+"\n") + file.close() + + print("phi = {}, L={},rng_seed={} simulation".format(phi,L,rng_seed)) + + config_filename=config_files_dir+str(rng_seed)+'.csv' + command = 'simulation '+params_file+' '+config_filename + os.system(command) + + print("phi = {}, L={},rng_seed={} lbp".format(phi,L,rng_seed)) + + rog_filename=results_dir+'lbp_'+str(rng_seed)+'.csv' + command = 'lb_bonds_clusterwise_invA ' + config_filename +' ' + rog_filename + os.system(command) + +def create_dirs_for_mk_table(dim): + + global D + + D = dim + + global params_dir + + + params_dir = './mk_table/params/' + path = Path(params_dir) + + try: + path.mkdir(parents=True, exist_ok=True) + except OSError: + pass + else: + pass + + + global results_dir + + results_dir = './mk_table/results/' + path = Path(results_dir) + + try: + path.mkdir(parents=True, exist_ok=True) + except OSError: + pass + else: + pass + + global config_files_dir + + config_files_dir = './mk_table/config_files/' + path = Path(config_files_dir) + + try: + path.mkdir(parents=True, exist_ok=True) + except OSError: + pass + else: + pass + +def run_simulation_for_random_params(phi, L, rng_seed): + + lattice=1 + x0_bc="periodic" + x1_bc="periodic" + x2_bc="periodic" + alpha=0.5 + seedMass=1e12 + seed_pct = 100 + + + params_file = params_dir+'params_'+str(rng_seed)+'.csv' + file = open(params_file, "w") + + file.write("system=random_site_percolation\n") + file.write("lattice="+str(lattice)+"\n") + file.write("aggregation_type=normal\n") + file.write("aggregation_condition=mass\n") + file.write("bind=normal\n") + file.write("movement=brownian\n") + file.write("agg_dist_tolerance=0.0\n") + file.write("D="+str(D)+"\n") + file.write("seed_pct="+str(seed_pct)+"\n") + file.write("x0_bc="+str(x0_bc)+"\n") + file.write("x1_bc="+str(x1_bc)+"\n") + file.write("x2_bc="+str(x2_bc)+"\n") + file.write("x0_L="+str(L)+"\n") + file.write("x1_L="+str(L)+"\n") + file.write("x2_L="+str(L)+"\n") + file.write("phi="+str(phi)+"\n") + file.write("alpha="+str(alpha)+"\n") + file.write("seedMass="+str(seedMass)+"\n") + file.write("rng_seed="+str(rng_seed)+"\n") + file.close() + + print("phi = {}, N={},rng_seed={} simulation".format(phi,L,rng_seed)) + + config_filename=config_files_dir+str(rng_seed)+'.csv' + command = 'simulation '+params_file+' '+config_filename + os.system(command) + + print("phi = {}, N={},rng_seed={} lbp".format(phi,L,rng_seed)) + + rog_filename=results_dir+'lbp_'+str(rng_seed)+'.csv' + time_filename=results_dir+'time_'+str(rng_seed)+'.csv' + command = 'lb_bonds_clusterwise_invA ' + config_filename +' ' + rog_filename + ' ' + time_filename + os.system(command) + +#phi=0.15 +seeds=100 +seed_pct=100 +dim = 2 + +L_range = [1000, 2000, 5000] + +phi_min = 0.005 +phi_max = 0.05 +phi_c = 0.5927462 + +phi_min += phi_c +phi_max += phi_c + +d_phi = 0.1 * (phi_max - phi_min) + +phi_range = [] + +for i in range(10): + + temp_phi = phi_min * np.exp(i * (d_phi)) + phi_range.append(temp_phi) + +for i in phi_range: + for L in L_range: + create_dirs(i, L, seed_pct, dim) + Parallel(n_jobs=10)(delayed(run_simulation)(i, L, seed_pct, rng_seed) for rng_seed in range(seeds)) \ No newline at end of file diff --git a/simulation_files/Makefile b/simulation_files/Makefile index ba48253..546e9ef 100644 --- a/simulation_files/Makefile +++ b/simulation_files/Makefile @@ -1,34 +1,34 @@ IDIR =./include CXX=g++ -CPPFLAGS=-g -I$(IDIR) -std=c++11 -O3 -w -LDFLAGS=-g -I$(IDIR) -std=c++11 -O3 -w +#CPPFLAGS=-g -I$(IDIR) -std=c++11 -O3 -w +#LDFLAGS=-g -I$(IDIR) -std=c++11 -O3 -w -#CPPFLAGS=-I$(IDIR) -std=c++11 -O3 -w -#LDFLAGS=-I$(IDIR) -std=c++11 -O3 -w +CPPFLAGS=-I$(IDIR) -std=c++11 -O3 -w +LDFLAGS=-I$(IDIR) -std=c++11 -O3 -w SRC_DIR = ./src OBJ_DIR = ./obj SRC_FILES = $(wildcard $(SRC_DIR)/*.cpp) OBJ_FILES = $(patsubst $(SRC_DIR)/%.cpp,$(OBJ_DIR)/%.o,$(SRC_FILES)) BIN_SRC_DIR = ./bin_src BIN_DIR = ./bin all: simulation simulation: $(OBJ_FILES) | $(BIN_DIR) $(CXX) $(CPPFLAGS) -c -o simulation.o target/simulation.cpp $(CXX) $(LDFLAGS) -o $(BIN_DIR)/$@ $^ simulation.o $(OBJ_DIR)/%.o: $(SRC_DIR)/%.cpp | $(OBJ_DIR) $(CXX) $(CPPFLAGS) -c -o $@ $< $(BIN_DIR): mkdir $(BIN_DIR) $(OBJ_DIR): mkdir $(OBJ_DIR) clean: rm -rf $(OBJ_DIR) rm *.o rm -rf $(BIN_DIR)