Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
…into dev
  • Loading branch information
Susan Redmond authored and Susan Redmond committed Jan 5, 2019
2 parents 616af40 + 70ab03e commit be538a6
Show file tree
Hide file tree
Showing 5 changed files with 34 additions and 8 deletions.
6 changes: 3 additions & 3 deletions docs/config_file_format.rst
Expand Up @@ -47,13 +47,13 @@ would be parsed, forming the dictionary:
Required Parameters
*******************

General
=======
General Parameters
==================
:code:`[general]` contains the following parameters:

:user_spec_nodes: **(nx3 numpy array of floats)** User-specified nodes (nodes with provided loads and displacement boundary conditions) in the format :code:`'[[x1 y1 z1],[x2 y2 z2],...,[xn yn zn]]'`.

:loads: **(nx6 numpy array of floats)** The forces and moments acting on each user-specified node in the format :code:`'[[Fx1,Fy1,Fz1,Mx1,My1,Mz1],[Fx2,Fy2,Fz2,Mx2,My2,Mz2],...,[Fxn,Fyn,Fzn,Mxn,Myn,Mzn]]'`.
:loads: **(nx6 numpy array of floats)** The forces and moments acting on each user-specified node in the format :code:`'[[Fx1,Fy1,Fz1,Mx1,My1,Mz1][Fx2,Fy2,Fz2,Mx2,My2,Mz2],...,[Fxn,Fyn,Fzn,Mxn,Myn,Mzn]]'`.

:fixtures: **(nx6 numpy array of ints)** The translational and rotational displacements for each user-specified node in the format :code:`'[[transx1,transy1,transz1,rotx1,roty1,rotz1],[transx2,transy2,transz2,rotx2,roty2,rotz2],...,[transxn,transyn,transzn,rotxn,rotyn,rotzn]]'`. Here :code:`transx1` is the translational degree of freedom in the x direction of the first user-specified node, and :code:`rotx1` is the rotational degree of freedom about the x-axis of the first user-specified node. A :code:`1` indicates fixed, while a :code:`0` indicates the node is free to move along or about the corresponding degree of freedom.

Expand Down
4 changes: 2 additions & 2 deletions gastop-config/boolean_parse_test_init.txt
Expand Up @@ -32,8 +32,8 @@ num_generations = 30
num_elite =
percent_mutation =
percent_crossover =
save_frequency = 5
save_filename_prefix = Recorded_States_
save_frequency =
save_filename_prefix =

[monitor_params]
progress_fitness = False
Expand Down
2 changes: 1 addition & 1 deletion gastop/genalg.py
Expand Up @@ -125,7 +125,7 @@ def initialize_population(self, pop_size=None):
for i in tqdm(range(pop_size), total=pop_size, leave=False, desc='Initializing Population', position=0):
self.population.append(self.generate_random())

def run(self, num_generations=None, progress_fitness=False, progress_truss=False, num_threads=None):
def run(self, num_generations=None, progress_fitness=None, progress_truss=None, num_threads=None):
'''Runs the genetic algorithm over all populations and generations
Args:
Expand Down
5 changes: 4 additions & 1 deletion tests/test_basic_optimization.py
Expand Up @@ -66,13 +66,16 @@
'boundary_conditions': {'loads': 0, 'fixtures': 0, },
'properties_dict': 0,
'cost_solver': 'blank_test'}
monitor_params = {'progress_fitness': False,
'progress_truss': False}

config = {'ga_params': ga_params,
'random_params': random_params,
'mutator_params': mutator_params,
'crossover_params': crossover_params,
'selector_params': selector_params,
'evaluator_params': evaluator_params}
'evaluator_params': evaluator_params,
'monitor_params': monitor_params}

pop_size = 1000

Expand Down
25 changes: 24 additions & 1 deletion tests/test_utilities.py
Expand Up @@ -33,10 +33,21 @@ def testInitFileParser(self):
self.assertTrue(config['general']['bool0'] is False)
self.assertTrue(config['general']['bool1'] is True)
self.assertTrue(config['general']['boolnone'] is None)
self.assertEqual(config['ga_params']
['config_save_name'], 'config.json')
self.assertEqual(config['ga_params']
['pop_save_name'], 'population.json')
self.assertEqual(config['ga_params']['save_frequency'], 0)

def testInitFileParser2(self):
"""tests edge cases for invalid file path"""

init_file_path = 'gastop-config/foo'
self.assertRaises(IOError, utilities.init_file_parser, init_file_path)


class TestTrussPlot(unittest.TestCase):
"""Test for plot method. Doesn't assert, visual inspection used for pass/fail"""
"""Test for plot and print methods. Doesn't assert, visual inspection used for pass/fail"""

def test_truss_plot(self):
"""Plots a pyramidal truss with loads and deflections."""
Expand All @@ -58,6 +69,18 @@ def test_truss_plot(self):
domain = np.array([[-1.5, 1.5], [-1.5, 1.5], [0, 1.5]]).T
truss.plot(domain, loads, fixtures, True, load_scale, def_scale)

def test_truss_print(self):
"""Prints a truss as formatted text"""

user_spec_nodes = np.array([[-1, -1, 0], [-1, 1, 0]])
rand_nodes = np.array([[1, 1, 0], [1, -1, 0], [0, 0, 1]])
edges = np.array([[0, 1], [1, 2], [2, 3], [3, 0],
[0, 4], [1, 4], [2, 4], [3, 4]])
properties = np.zeros(8)

truss = Truss(user_spec_nodes, rand_nodes, edges, properties)
print(truss)


if __name__ == "__main__":
unittest.main()

0 comments on commit be538a6

Please sign in to comment.