|
GraphNet: Discrete element modeling for network connected materials
Applications to polymeric networks
|
#include <network.h>

Public Member Functions | |
| Network () | |
| Implements a network of discrete chains. More... | |
| Network (Network const &source) | |
| Copy constuctor for class Network. More... | |
| Network (string &fname, bool from_dump=false) | |
| Constructor that instantiates a Network object according to given {fname} file. Please note that there are no checks made on the GMSH .msh filepath and that responsibility is left to the user. More... | |
| virtual | ~Network () |
| Destructor for class network. More... | |
| Network const & | operator= (Network const &other) |
| Overloads assignment operator (=) to implement copy constructor. More... | |
| virtual void | build_network () |
| This function is for users to build custom networks. It has no body and implements nothing. More... | |
| void | side_nodes (float max_x=MAXBOUND_X, float max_y=MAXBOUND_Y) |
| Gives the boundary nodes for a network. More... | |
| void | remove_duplicates (int &) |
| Removes duplicate edges. A much more efficient version can be made of this program. But it is called only once in the simulation, so this should be fine. More... | |
| void | add_long_range_egdes_y (int, float) |
| Adds y-directional long range edges to the network. Chooses two nodes uniformly at random from the n_add divisions in x_direction such that the distance between them is at least 0.25*L_MEAN and at max L_MEAN. More... | |
| void | add_long_range_egdes_random (int, float) |
| Adds random long range edges to the network. Chooses two nodes uniformly at random and adds an edge with x/L = 0.25 (i.e. prestressed) More... | |
| void | load_from_dump (string &) |
| This function loads the last network state from a dump file. This is called by the Network constructor load_from_dump is set to true. Do not load from dump if network has already broken. More... | |
| void | apply_crack (Cracklist &) |
| Adds random cracks in the Network object. This is implemented by removing all connections and nodes that lie {entirely} within the ellipses specified in alist. Please note this assumption may be relaxed and a probabilistic measure may be introduced to remove some connections so as to simulate small world networks (cluster networks) This is managed by the PROB_REMOVAL parameter in params.h. More... | |
| virtual void | load_network (string &) |
| This function builds the network. It includes building PBC bonds. The function initializes all properties required for running experiments on the instantiated Network code. This is called by constructor of a Network object. User is discouraged from directly calling this function. More... | |
| virtual void | malloc_network () |
| This function allocates memory for all class data members. This is called by the Network constructor if the same is called using a filepath string. User is discouraged from directly calling this function. More... | |
| void | make_edge_connections (float dely_allowed=10.0) |
| Adds PBC bonds to the network according to dely_allowed. More... | |
| virtual void | get_forces (bool) |
| Calculates forces along edges of the polymer network graph (i.e forces in each polymer). The forces are then assigned to nodes which prepares the network for the optimization step. If update_damage is true, the appropriate damage metric is also updated. If damage exceeds predefined thresholds, the edge is broken. In case of a sacNetwork object hidden lengths are also opened according to damage in these hidden bonds apart from end damage. The function does not return anything as it updates the objects forces directly. More... | |
| virtual void | move_top_plate () |
| Moves the top plate according to velocity supplied in vel.h. More... | |
| virtual void | get_plate_forces (float *, int) |
| Writes the forces on the top plate the supplied plate_forces array. More... | |
| virtual void | optimize (float eta=0.1, float alpha=0.9, int max_iter=800) |
| Equilibriates the Network object using RMSProp algorithm due to G. Hinton et al (a gradient based force minimization over each node). Stops when maximum force on node is less than TOL specified in params.h or max_iter is reached. More... | |
| virtual void | qd_optimize (float C=0.001, int max_iter=800) |
| Equilibriates the Network object using an Implicit scheme based on solving the quasi-dynamic equation. More... | |
| float | get_weight () |
| Gets the total length of all polymer chains active in the network. More... | |
| float | set_weight (float) |
| Sets the total length of all polymer chains according to supplied weight parameter. Also prints out the new average polymer contour lengths. More... | |
| bool | get_stats (float force_threshold=1000.0) |
| Prints out certain statistics of the network object. More... | |
| int | get_current_edges () |
| Gets the active (load-bearing) edges in the Network object. Also prints out that info to STDOUT or piped OUT. More... | |
| virtual void | plotNetwork (int, bool) |
| Plots the graph of the network. Note the edges in the graph just signify connection between two nodes and do not represent the actual polymer geometry in any sense. Note that this plot will be saved as .png file in the folder specified by FLDR_STRING in params.h. More... | |
| virtual void | clear () |
| Called by destructor of Network objects to clear variables from memory. More... | |
| void | copy (Network const &source) |
| Implements the body of the copy constuctor. Allocates memory and does the appropriate assignments. More... | |
| void | dump (int, bool first_time=false) |
| Dumps the network information for an iteration in a file. Filename would be <FLDR_STRING>.txt with <FLDR_STRING taken from params.h If <FLDR_STRING>.txt exists, <FLDR_STRING>_i.txt would be created where i is an integer decided based on copies present in current folder. More... | |
Public Attributes | |
| bool | cracked |
| Flag to check if the network has cracks. More... | |
| int | n_nodes |
| Stores number of crosslinker nodes in the network. More... | |
| int | n_elems |
| Stores number of polymer connections in the network. More... | |
| int | n_rside |
| Stores number of crosslinker nodes on the right edge of the network sample. More... | |
| int | n_lside |
| Stores number of crosslinker nodes on the left edge of the network sample. More... | |
| int | n_bside |
| Stores number of crosslinker nodes on the bottom edge of the network sample. More... | |
| int | n_tside |
| Stores number of crosslinker nodes on the top edge of the network sample. More... | |
| float * | R |
| Stores the position of all nodes of the graph in a flat n_nodes*DIM size array. More... | |
| int * | edges |
| Stores the i,j pairs that form edges, size is n_elems*2. More... | |
| float * | forces |
| Stores the forces on all nodes of the network in a flat n_nodes*DIM size array. More... | |
| float * | damage |
| Stores the damage in each edge of the network. More... | |
| float * | L |
| Stores the contour length of the edge. More... | |
| bool * | PBC |
| Tag to check if an edge is a periodic boundary condition edge. More... | |
| int * | lsideNodes |
| Stores index of crosslinker nodes on the left edge of the network sample. More... | |
| int * | rsideNodes |
| Stores index of crosslinker nodes on the right edge of the network sample. More... | |
| int * | tsideNodes |
| Stores index of crosslinker nodes on the top edge of the network sample. More... | |
| int * | bsideNodes |
| Stores index of crosslinker nodes on the bottom edge of the network sample. More... | |
| bool | initialized |
| Internal variable to check if Network object is initialized. More... | |
| float | __init_force |
| Initial force on the plate (simulation stopped if force goes below this.) More... | |
| float | weight_multiplier = 1.0 |
| Weight multiplier in case of weight increases. More... | |
| int | iter_offset = 0 |
| Offsets iterations in the figure names, if starting where a previous simulation ended. More... | |
| int * | moving_nodes |
| Stores index of all nodes where no boundary condition is applied (i.e. they participate in optimization) More... | |
| int | n_moving |
| Stores number of moving nodes. More... | |
| Network::Network | ( | ) |
Implements a network of discrete chains.
Default constructor.
< This is the base class that takes in a GMSH .msh file to build a network. All edges in the mesh generated from GMSH are taken as edges of the network. The nodes in the mesh are taken as cross-linker positions and the edges as polymers.
All properties relevant to the computational experiments are initialized. Experiments are then member functions that can be called.
| Network::Network | ( | Network const & | source | ) |
| Network::Network | ( | string & | fname, |
| bool | from_dump = false |
||
| ) |
|
virtual |
Destructor for class network.
| void Network::add_long_range_egdes_random | ( | int | n_add, |
| float | prestretch | ||
| ) |
Adds random long range edges to the network. Chooses two nodes uniformly at random and adds an edge with x/L = 0.25 (i.e. prestressed)
| void Network::add_long_range_egdes_y | ( | int | n_add, |
| float | prestretch | ||
| ) |
Adds y-directional long range edges to the network. Chooses two nodes uniformly at random from the n_add divisions in x_direction such that the distance between them is at least 0.25*L_MEAN and at max L_MEAN.
| n_add | number of long range y-connections to add |
| prestrech | float between 0.01,0.99 to give initial x/L of these long range bonds If value is not between (0.01,0.99), 0.25 is assumed |
| void Network::apply_crack | ( | Cracklist & | alist | ) |
Adds random cracks in the Network object. This is implemented by removing all connections and nodes that lie {entirely} within the ellipses specified in alist. Please note this assumption may be relaxed and a probabilistic measure may be introduced to remove some connections so as to simulate small world networks (cluster networks) This is managed by the PROB_REMOVAL parameter in params.h.
| alist | (Cracklist) –> A list of ellipses |
|
virtual |
This function is for users to build custom networks. It has no body and implements nothing.
|
virtual |
Called by destructor of Network objects to clear variables from memory.
Reimplemented in MPI_Network, and sacNetwork.
| void Network::copy | ( | Network const & | source | ) |
| void Network::dump | ( | int | iter, |
| bool | first_time = false |
||
| ) |
Dumps the network information for an iteration in a file. Filename would be <FLDR_STRING>.txt with <FLDR_STRING taken from params.h If <FLDR_STRING>.txt exists, <FLDR_STRING>_i.txt would be created where i is an integer decided based on copies present in current folder.
/param iter The iteration number for the simulation
| int Network::get_current_edges | ( | ) |
Gets the active (load-bearing) edges in the Network object. Also prints out that info to STDOUT or piped OUT.
|
virtual |
Calculates forces along edges of the polymer network graph (i.e forces in each polymer). The forces are then assigned to nodes which prepares the network for the optimization step. If update_damage is true, the appropriate damage metric is also updated. If damage exceeds predefined thresholds, the edge is broken. In case of a sacNetwork object hidden lengths are also opened according to damage in these hidden bonds apart from end damage. The function does not return anything as it updates the objects forces directly.
| update_damage | (bool) –> flag to update damage |
Reimplemented in MPI_Network, and sacNetwork.
|
virtual |
Writes the forces on the top plate the supplied plate_forces array.
/param plate_forces (float*) –> storage array for plate_forces /param iter (int) –> force_{i} stored in plate_forces[iter*DIM + i] i = 0 ... DIM - 1 /param max_iter (int) –> maximum iterations to be allowed in descent
| bool Network::get_stats | ( | float | curr_force = 1000.0 | ) |
Prints out certain statistics of the network object.
/param curr_force –> takes in curr_force on plate, returns True, if curr_force <= 0.1*__init_force
| float Network::get_weight | ( | ) |
Gets the total length of all polymer chains active in the network.
| void Network::load_from_dump | ( | string & | dname | ) |
This function loads the last network state from a dump file. This is called by the Network constructor load_from_dump is set to true. Do not load from dump if network has already broken.
| dname | (string) –> dump filename |
|
virtual |
This function builds the network. It includes building PBC bonds. The function initializes all properties required for running experiments on the instantiated Network code. This is called by constructor of a Network object. User is discouraged from directly calling this function.
| fname | (string) –> string of the .msh filepath |
Reimplemented in sacNetwork.
| void Network::make_edge_connections | ( | float | dely_allowed = 10.0 | ) |
Adds PBC bonds to the network according to dely_allowed.
| dely_allowed(float) | –> Connects two nodes i and j on the two sides of the network respectively iff $abs(y_i - y_j) < $dely_allowed |
|
virtual |
This function allocates memory for all class data members. This is called by the Network constructor if the same is called using a filepath string. User is discouraged from directly calling this function.
Reimplemented in sacNetwork.
|
virtual |
Moves the top plate according to velocity supplied in vel.h.
Overloads assignment operator (=) to implement copy constructor.
|
virtual |
Equilibriates the Network object using RMSProp algorithm due to G. Hinton et al (a gradient based force minimization over each node). Stops when maximum force on node is less than TOL specified in params.h or max_iter is reached.
/param eta (float) –> learning rate /param alpha (float) –> history weighting parameter /param max_iter (int) –> maximum iterations to be allowed in descent
|
virtual |
Plots the graph of the network. Note the edges in the graph just signify connection between two nodes and do not represent the actual polymer geometry in any sense. Note that this plot will be saved as .png file in the folder specified by FLDR_STRING in params.h.
| iter_step | (int) –> The iteration number of the experiment. This number will also be the filename for the .png file |
| first_time | (bool) –> This just effects what quantity is mapped to the color of the graph. If True, colors represent magnitude of forces in the polymer else, they represent the damage in a polymer connection |
|
virtual |
Equilibriates the Network object using an Implicit scheme based on solving the quasi-dynamic equation.
/param C –> damping coefficient /param max_iter –> maximum allowable iterations in the implicit scheme
| void Network::remove_duplicates | ( | int & | n_elems | ) |
Removes duplicate edges. A much more efficient version can be made of this program. But it is called only once in the simulation, so this should be fine.
| float Network::set_weight | ( | float | weight | ) |
Sets the total length of all polymer chains according to supplied weight parameter. Also prints out the new average polymer contour lengths.
/param weight (float) –> Weight goal required.
| void Network::side_nodes | ( | float | max_x = MAXBOUND_X, |
| float | max_y = MAXBOUND_Y |
||
| ) |
Gives the boundary nodes for a network.
| float Network::__init_force |
Initial force on the plate (simulation stopped if force goes below this.)
| int* Network::bsideNodes |
Stores index of crosslinker nodes on the bottom edge of the network sample.
| bool Network::cracked |
Flag to check if the network has cracks.
| float* Network::damage |
Stores the damage in each edge of the network.
| int* Network::edges |
Stores the i,j pairs that form edges, size is n_elems*2.
| float* Network::forces |
Stores the forces on all nodes of the network in a flat n_nodes*DIM size array.
| bool Network::initialized |
Internal variable to check if Network object is initialized.
| int Network::iter_offset = 0 |
Offsets iterations in the figure names, if starting where a previous simulation ended.
| float* Network::L |
Stores the contour length of the edge.
| int* Network::lsideNodes |
Stores index of crosslinker nodes on the left edge of the network sample.
| int* Network::moving_nodes |
Stores index of all nodes where no boundary condition is applied (i.e. they participate in optimization)
| int Network::n_bside |
Stores number of crosslinker nodes on the bottom edge of the network sample.
| int Network::n_elems |
Stores number of polymer connections in the network.
| int Network::n_lside |
Stores number of crosslinker nodes on the left edge of the network sample.
| int Network::n_moving |
Stores number of moving nodes.
| int Network::n_nodes |
Stores number of crosslinker nodes in the network.
| int Network::n_rside |
Stores number of crosslinker nodes on the right edge of the network sample.
| int Network::n_tside |
Stores number of crosslinker nodes on the top edge of the network sample.
| bool* Network::PBC |
Tag to check if an edge is a periodic boundary condition edge.
| float* Network::R |
Stores the position of all nodes of the graph in a flat n_nodes*DIM size array.
| int* Network::rsideNodes |
Stores index of crosslinker nodes on the right edge of the network sample.
| int* Network::tsideNodes |
Stores index of crosslinker nodes on the top edge of the network sample.
| float Network::weight_multiplier = 1.0 |
Weight multiplier in case of weight increases.
1.8.11