nns.c  1.0.1
Nanowire Network simulator
network.h File Reference

Defines the structures and functions used to model and simulate the topology and electrical state of a Nanowire Network. More...

#include "datasheet.h"
#include "junction.h"
#include "wire.h"

Go to the source code of this file.

Classes

struct  network_topology
 Topology of the Nanowire Network. It contains information about the physical placement of nanowires and junctions in the package. More...
 
struct  network_state
 Electrical state of the Nanowire Network. It contains the varying values of the junctions and the voltage distribution in the network nanowires. More...
 

Functions

network_topology create_network (const datasheet ds, int n2c[], int *ccs_count)
 Create the Nanowire Network topology determining the wires and junctions distribution. The function produces a network topology whose nanowires and junctions are sorted according to their parent connected component. Also returns the mapping between nodes index and parent connected component index. More...
 
network_state construe_circuit (const datasheet ds, const network_topology nt)
 Construe the equivalent electrical circuit of the Nanowire Network. Both nanowires and junctions are ordered according to their parent connected component. More...
 
int ntcmp (const void *e1, const void *e2)
 Compare two network topologies according to the number of junctions. More...
 
network_topology copy_topology (const datasheet ds, const network_topology nt)
 Create a deep copy of a network topology. More...
 
network_state copy_state (const datasheet ds, const network_topology nt, const network_state ns)
 Create a deep copy of a network state. More...
 
void destroy_topology (network_topology nt)
 Destroy a network topology memorized in the stack. This function practically frees the wires and junctions arrays of the network topology. The arrays to be freed must have been allocated in the heap with malloc/calloc. More...
 
void destroy_state (network_state ns)
 Destroy a network state memorized in the stack. This function practically frees Ys and Vs arrays of the network state. The arrays to be freed must have been allocated in the heap with malloc/calloc. More...
 

Detailed Description

Defines the structures and functions used to model and simulate the topology and electrical state of a Nanowire Network.

This file contains the necessary data structures and function declarations to represent a Nanowire Network, including the physical layout of nanowires and junctions, and the electrical properties such as voltage distribution and admittances. It also provides utilities for creating, copying, comparing, and destroying network topologies and states.

Note
The structures here defined use dynamically allocated memory that must be managed using the provided functions.

Function Documentation

◆ construe_circuit()

network_state construe_circuit ( const datasheet  ds,
const network_topology  nt 
)

Construe the equivalent electrical circuit of the Nanowire Network. Both nanowires and junctions are ordered according to their parent connected component.

Parameters
[in]dsThe datasheet describing the Nanowire Network.
[in]ntThe topology of the Nanowire Network.
Returns
The electrical representation of the Nanowire Network.

◆ copy_state()

network_state copy_state ( const datasheet  ds,
const network_topology  nt,
const network_state  ns 
)

Create a deep copy of a network state.

Parameters
[in]dsThe datasheet describing the network.
[in]ntThe topology of the network.
[in]nsThe network state to copy.
Returns
The deep copy of the network state.

◆ copy_topology()

network_topology copy_topology ( const datasheet  ds,
const network_topology  nt 
)

Create a deep copy of a network topology.

Parameters
[in]dsThe datasheet describing the network.
[in]ntThe network topology to copy.
Returns
The deep copy of the network topology.

◆ create_network()

network_topology create_network ( const datasheet  ds,
int  n2c[],
int *  ccs_count 
)

Create the Nanowire Network topology determining the wires and junctions distribution. The function produces a network topology whose nanowires and junctions are sorted according to their parent connected component. Also returns the mapping between nodes index and parent connected component index.

Parameters
[in]dsThe datasheet describing the Nanowire Network to realize.
[out]n2cThe output mapping between nodes index and parent connected component index.
[out]ccs_countThe number of connected components discovered.
Returns
The topology of the created Nanowire Network.

◆ destroy_state()

void destroy_state ( network_state  ns)

Destroy a network state memorized in the stack. This function practically frees Ys and Vs arrays of the network state. The arrays to be freed must have been allocated in the heap with malloc/calloc.

Parameters
[in,out]nsThe network state to destroy.

◆ destroy_topology()

void destroy_topology ( network_topology  nt)

Destroy a network topology memorized in the stack. This function practically frees the wires and junctions arrays of the network topology. The arrays to be freed must have been allocated in the heap with malloc/calloc.

Parameters
[in,out]ntThe network topology to destroy.

◆ ntcmp()

int ntcmp ( const void *  e1,
const void *  e2 
)

Compare two network topologies according to the number of junctions.

Parameters
[in]e1Pointer to the first element to compare.
[in]e2Pointer to the second element to compare.
Returns
0 if the topologies contain the same amount of junctions; > 0 if e1 has more junctions than e2; < 0 otherwise.