Skip to content

Structure

This module contains implementations for defining structures in terms of a collection of areas and view factors.

machball.structure

Structure

Implement a geometrical feature as an array of areas and view factors.

A Structure is just an array of areas and view factors. It optionally allows to define regions as either individual indices or as slices.

Parameters:

Name Type Description Default
areas array

1D array with the areas of each element in the structure

required
qij array

2D array with the view factors for all the elements. qij[i,j] represents the view factor of section i from section j

required
regions dict of list of ints

a dictionary partitioning the structure into a series of regions

None
coords iterable object

a list of elements containing geometrical information on each structure

None

save_structure(filename, st, mode='pickle', areafile=None)

Save a structure to a file

There are two options: saving the structure as a pickle, which retains all metadata (entrypoints, coordinates, regions), or just the view factors and areas as numpy arrays. In this second case, if areafile is provided the view factors and areas are saved in different files. Otherwise, the areas are saved as a first column of a NxN+1 array.

Parameters:

Name Type Description Default
filename str

file name

required
st Structure

the structure to be saved

required
mode (pickle, numpy)

If "pickle" saves it as pickle.

'pickle'
areafile str

Optional additional filename for storing the areas when saving as numpy array.

None

read_structure(filename, mode='pickle', areafile=None)

Read a Structure from file

There are two options: reading the structure as a pickle or as numpy arrays. In this second case, if an optional areafile is provided the areas are retrieved from that file. Otherwise, the areas are saved as a first column of a NxN+1 array in filename.

Parameters:

Name Type Description Default
filename str

file name

required
mode (pickle, numpy)

If "pickle" saves it as pickle.

'pickle'
areafile str

Optional additional filename for storing the areas when saving as numpy array.

None

Returns:

Name Type Description
st Structure

structure read from file