14.6.5. Parallel Parametric Study ExampleΒΆ
- The source code is shown below, which can be downloaded
here
. - Run the source code with 2 processors
mpiexec -np 2 python paralleltruss2.py
the outputs look like
Processor 0
Node 4 (E = 3000.0 ) Disp : [0.5300927771322836, -0.17789363846931766]
Processor 1
Node 4 (E = 6000.0 ) Disp : [0.2650463885661418, -0.08894681923465883]
Process 1 Terminating
Process 0 Terminating
The script is shown below
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 | import openseespy.opensees as ops
pid = ops.getPID()
np = ops.getNP()
ops.start()
if np != 2:
exit()
ops.model('basic', '-ndm', 2, '-ndf', 2)
if pid == 0:
E = 3000.0
else:
E = 6000.0
ops.uniaxialMaterial('Elastic', 1, E)
ops.node(1, 0.0, 0.0)
ops.node(2, 144.0, 0.0)
ops.node(3, 168.0, 0.0)
ops.node(4, 72.0, 96.0)
ops.fix(1, 1, 1)
ops.fix(2, 1, 1)
ops.fix(3, 1, 1)
ops.element('Truss', 1, 1, 4, 10.0, 1)
ops.timeSeries('Linear', 1)
ops.pattern('Plain', 1, 1)
ops.load(4, 100.0, -50.0)
ops.element('Truss', 2, 2, 4, 5.0, 1)
ops.element('Truss', 3, 3, 4, 5.0, 1)
ops.constraints('Transformation')
ops.numberer('ParallelPlain')
ops.system('Umfpack')
ops.test('NormDispIncr', 1e-6, 6)
ops.algorithm('Newton')
ops.integrator('LoadControl', 0.1)
ops.analysis('Static')
ops.analyze(10)
if pid == 0:
print('Processor 0')
print('Node 4 (E =', E, ') Disp :', ops.nodeDisp(4))
ops.barrier()
if pid == 1:
print('Processor 1')
print('Node 4 (E =', E, ') Disp :', ops.nodeDisp(4))
ops.stop()
|