utilities Module

Useful procedures when doing percolation.


Used by

  • module~~utilities~~UsedByGraph module~utilities utilities module~percolation percolation module~percolation->module~utilities module~randomwalk randomwalk module~randomwalk->module~utilities module~randomwalk->module~percolation

Contents


Variables

TypeVisibility AttributesNameInitial
integer, public, parameter:: dp =kind(1.0d0)

Kind used for all real variables.


Functions

public function stringfromint(x)

Make a string of "correct" length from a positive integer.

Arguments

Type IntentOptional AttributesName
integer, intent(in) :: x

Positive integer to be converted.

Return Value character(len=:), allocatable

String containing the given integer, without spaces.

public function linspace(a, b, N)

Create an array of N linearly spaced values (not intervals) from a to b. Similar to numpy.linspace(a, b, N).

Arguments

Type IntentOptional AttributesName
real(kind=dp), intent(in) :: a

Lower endpoint.

real(kind=dp), intent(in) :: b

Upper endpoint.

integer, intent(in) :: N

Number of values (not intervals).

Return Value real(kind=dp), dimension(:), allocatable

Array of linearly spaced values.

public function find_intersection(array1, array2, num_labels) result(intersect_label)

Find the common element in two arrays, given a total of num_labels unique elements. Used by find_spanning_cluster.

Arguments

Type IntentOptional AttributesName
integer, intent(in), dimension(:):: array1

Array to analyse.

integer, intent(in), dimension(:):: array2

Array to analyse.

integer, intent(in) :: num_labels

The known number of unique non-zero elements.

Return Value integer

The first non-zero common element.

public function mark_percolating_with_periodic(label_matrix, percolating_label, num_clusters) result(matrix)

Return a logical matrix where the .true. values are the sites belonging to the percolating cluster, when periodic boundary conditions are considered.

Arguments

Type IntentOptional AttributesName
integer, intent(in), dimension(:,:):: label_matrix

Labelled matrix from label or hoshen_kopelman.

integer, intent(in) :: percolating_label

Known label of the percolating cluster.

integer, intent(in) :: num_clusters

The known number of clusters.

Return Value logical, dimension(:,:), allocatable

Matrix where the .true. values are the sites belonging to the percolating cluster with periodic boundary conditions.


Subroutines

public subroutine linfit(x, y, slope, const)

Compute a linear fit for the given data, return the slope and the constant term. dgels from LAPACK solves the linear least squares problem.

Arguments

Type IntentOptional AttributesName
real(kind=dp), intent(in), dimension(:):: x

Values to be fitted.

real(kind=dp), intent(in), dimension(:):: y

Values to be fitted.

real(kind=dp), intent(inout) :: slope

\(a\) in \(y=ax+b\).

real(kind=dp), intent(inout) :: const

\(b\) in \(y=ax+b\).

public subroutine find_random_point(matrix, i, j)

Find a random position on matrix such that matrix(i, j) is .true..

Arguments

Type IntentOptional AttributesName
logical, intent(in), dimension(:,:):: matrix

Matrix whose .true. values are allowed positions for the random walker.

integer, intent(out) :: i

Returned random point on matrix.

integer, intent(out) :: j

Returned random point on matrix.

public subroutine periodic_wraparound(x, L)

Arguments

Type IntentOptional AttributesName
integer, intent(inout) :: x
integer, intent(in) :: L