A simple SEA model of two beams


In [1]:
import sys
import seapy
import numpy as np
%matplotlib inline

Creating a SEA model

To create a SEA model we begin by creating an instance of Model.


In [2]:
from acoustics.signal import OctaveBand

frequency = OctaveBand(fstart=500.0, fstop=8000.0, fraction=1)
system1 = seapy.system.System(frequency)

We are only interested in a limited frequency range.

system1.frequency.center = [500.0, 1000.0, 2000.0, 4000.0, 8000.0] system1.frequency.lower = [355.0, 710.0, 1420.0, 2840.0, 5680.0] system1.frequency.upper = [710.0, 1420.0, 2840.0, 5680.0, 11360.0] system1.frequency.enabled = [False, False, True, True, True]

An important parameter of a component is the type of which it is made. Let's create steel beams.


In [3]:
steel = system1.add_material('steel', 
                             'MaterialSolid', 
                             young=1.0e7, 
                             poisson=0.30, 
                             density=8.0e3,
                             loss_factor=np.ones(len(system1.frequency.center))*0.2
                            )

While we gave certain quantities as arguments, we can also assign them later on.


In [8]:
steel.density = 2000.0

We now create two almost similar beams.


In [9]:
beam1 = system1.add_component(
    'beam1',               
    'Component1DBeam',
    material='steel',
    length=2.0,
    width=0.5,
    height=0.6
)


/home/freddy/code/other/seapy/seapy/base.py:349: NameWarning: Name beam1 is not unique.
  warnings.warn(msg, NameWarning)

In [10]:
beam2 = system1.add_component(
    'beam2', 
    'Component1DBeam', 
    material='steel', 
    length=2.0, 
    width=0.5,
    height=0.6,
)

When we now check the steel material, we can see it is used by these two beams.


In [11]:
for component in steel.linked_components:
    print(component)


Component(beam2)
Component(beam1)
Component(beam11)
Component(beam1)

Let's have a look at the subsystems we have now.


In [12]:
for subsystem in system1.subsystems:
    subsystem.name

Indeed, we have six subsystems. Each structural component has by default subsystems representing longitudinal, bending and shear waves.


In [13]:
for i in beam1.linked_subsystems:
    print(i)


Subsystem(beam11_SubsystemBend)
Subsystem(beam11_SubsystemLong)
Subsystem(beam11_SubsystemShear)

We can now plot attributes ofa subsystem, e.g. the group speed.


In [14]:
fig = beam1.subsystem_long.plot('soundspeed_group')


---------------------------------------------------------------------------
MaskError                                 Traceback (most recent call last)
<ipython-input-14-3be510c73e82> in <module>
----> 1 fig = beam1.subsystem_long.plot('soundspeed_group')

~/code/other/seapy/seapy/base.py in plot(self, quantity, yscale)
    608             quantity,
    609             self.frequency.enabled,
--> 610             yscale=yscale,
    611         )
    612 

~/code/other/seapy/seapy/tools.py in plot(x, y, quantity, visible, yscale)
     48     fig = plt.figure()
     49     ax = fig.add_subplot(111)
---> 50     for i in y:
     51         ax.scatter(x, i)
     52     ax.set_xscale("log")

~/code/other/seapy/seapy/tools.py in <genexpr>(.0)
     39     mask = ~visible.astype(bool)
     40     x = ma.masked_array(x, mask=mask).compressed()
---> 41     y = (ma.masked_array(i, mask=mask).compressed() for i in y)
     42 
     43     try:

/nix/store/qy9rjr5wwmx203bf32y7kxvlfz4ppmmc-python3.7-numpy-1.18.1/lib/python3.7/site-packages/numpy/ma/core.py in __new__(cls, data, mask, dtype, copy, subok, ndmin, fill_value, keep_mask, hard_mask, shrink, order, **options)
   2870                     msg = "Mask and data not compatible: data size is %i, " + \
   2871                           "mask size is %i."
-> 2872                     raise MaskError(msg % (nd, nm))
   2873                 copy = True
   2874             # Set the mask to the new value

MaskError: Mask and data not compatible: data size is 25, mask size is 5.

Let's check the modal density of longitudinal waves in the first beam.


In [ ]:
fig = beam1.subsystem_long.plot('modal_density')

The modal density increases with frequency.. The modal density of bending waves however remains constant on a logarithmic scale.


In [ ]:
fig = beam1.subsystem_bend.plot('modal_density')

Now, let's connect the two beams with their tips.


In [ ]:
connection1 = system1.addConnection('connection1', 'Connection', shape='Point')
connection1.addComponent(beam1, 'corner')
connection1.addComponent(beam2, 'corner')

In [ ]:
for i in system1.connections:
    print(i)

Indeed, the connection we just made has connects two components.


In [ ]:
print((len(connection1.components)))

In [ ]:
from weakref import WeakValueDictionary

d = WeakValueDictionary()

d['beam1'] = system1._objects[1]
d['material'] = system1._objects[0]
print(len(d))

system1.removeObject('beam1')

print(len(d))

In [ ]:

#! /usr/bin/env python3 def main(): """""" """Oh, we shouldn't forget to set the density""" #print (steel.__class__.__dict__) """""" beam1 = system1.addComponent('beam1', 'Component1DBeam', material='steel', volume=10.0, length=2.0, cross_section=0.30) #beam2 = system1.addComponent('beam2', 'Component1DBeam', material='steel', volume=40.0, length=2.0, cross_section=0.30) ##beam1.linked_subsystems = 3 #print( beam1.__dict__['linked_subsystems']) #for item in beam1.linked_subsystems: #print (item) #for item in steel.linked_components: #print (item) #print (steel) #system1.removeObject('steel') #print (system1.objects) #print('testesddsfssdf') #print(item.name for item in beam1.linked_subsystems) #print(steel.linked_components) #print(type(steel.linked_components)) #print( beam1.volume ) #print( beam2.volume ) #print( beam1.area_moment_of_inertia ) #print( beam2.area_moment_of_inertia ) ##"""We can have a look at for instance their bending stiffnesses""" #print( beam1.bending_stiffness ) #print( beam2.bending_stiffness ) ##"""indeed, the second beam is more stiff.""" ##"""Next step is to define the subsystems. In this example we will only be including longitudinal waves.""" ###subsystem1 = system1.addSubsystem('sub1', 'long', 'beam1') ###subsystem2 = system1.addSubsystem('sub2', 'long', 'beam2') ##"""Then we add the connections. We connect the beams at their tips so it will be a 1D connection.""" ##connection1 = system1.addConnection('connection1', 'Connection', shape='Point') ##connection1.addComponent(beam1, 'corner') ##connection1.addComponent(beam2, 'corner') ##"""Let's excite the system with longitudinal waves in the first beam.""" ##subsystem1 = beam1.subsystem_long ##excitation1 = subsystem1.addExcitation('excitation1', 'ExcitationRain', power=[1.0, 1.0, 1.0, 1.0]) ##"""Let's have a look at the modal densities before we start the computation.""" ###subsystem1.plot_modal_density('modal_density_subsystem1.png') ###subsystem2.plot_modal_density('modal_density_subsystem2.png') ###print subsystem1.component.volume ###print steel.linked_components ###"""Finally, we solve for the modal powers""" ##system1.solveSystem() ###"""And indeed, the system is solved.""" ###print system1.solved ###"""Now we can plot for instance the velocity levels in the subsystems.""" ###subsystem1.plot_velocity_level('velocity_level_subsystem1.png') ###subsystem2.plot_velocity_level('velocity_level_subsystem2.png') ###"""Or the velocity levels in the components, which is given by a summation over its related subsystems.""" ###beam1.plot_velocity_level('velocity_level_beam1.png') ###beam2.plot_velocity_level('velocity_level_beam2.png') ###"""Since we included only one subsystem per component, the results are the same.""" if __name__ == "__main__": main()

Solving the system

Now that the entire system is set up we can solve for the modal powers.


In [ ]:
system1.solveSystem()

An indicator is present to show whether the system was solved. Note however that changes made in the model since solving the system do NOT change the value of this indicator.


In [ ]:
print(system1.solved)

Plotting results

We can now plot the velocity levels in the components


In [ ]:
fig = beam1.plot('velocity_level')

    ###subsystem2.plot_velocity_level('velocity_level_subsystem2.png')
       
    ###"""Or the velocity levels in the components, which is given by a summation over its related subsystems."""
    ###beam1.plot_velocity_level('velocity_level_beam1.png')
    ###beam2.plot_velocity_level('velocity_level_beam2.png')    
    ###"""Since we included only one subsystem per component, the results are the same."""

and/or subsystems.


In [ ]:
fig = beam1.subsystem_bend.plot('velocity_level')

In [ ]: