-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
22 changed files
with
485 additions
and
48 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
# AcoustiBase | ||
::: src.acoustipy.Database |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
# AcousticID | ||
::: src.acoustipy.Params |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
# AcousticTMM | ||
::: src.acoustipy.TMM | ||
handler: python |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
# Hybrid Characterization | ||
Use a hybrid characterization method to identify parameters of the Johnson-Champoux-Allard model given data obtained from an impedance tube. | ||
|
||
```python | ||
from acoustipy import AcousticTMM, AcousticID | ||
|
||
# Create an AcousticTMM object to generate toy impedance tube data | ||
structure = AcousticTMM(incidence='Normal',air_temperature = 20) | ||
|
||
# Define the JCA and air gap material parameters for the toy data | ||
layer1 = structure.Add_JCA_Layer(30, 46182,.917,2.1,83,128) | ||
air = structure.Add_Air_Layer(thickness = 100) | ||
|
||
# Generate rigid backed reflection data and save to a csv file | ||
s1 = structure.assemble_structure(layer1) | ||
A1 = structure.reflection(s1) | ||
structure.to_csv('no_gap',A1) | ||
|
||
# Generate air backed reflection data and save to a csv file | ||
s2 = structure.assemble_structure(layer1,air) | ||
A2 = structure.reflection(s2) | ||
structure.to_csv('gap',A2) | ||
|
||
# Create an AcousticID object, specifying to mount types, data files, and data types | ||
inv = AcousticID(mount_type='Dual',no_gap_file="no_gap.csv",gap_file = "gap.csv",input_type='reflection',air_temperature=20) | ||
|
||
# Call the Hybrid method to find the tortuosity, viscous, and thermal characteristic lengths of the material | ||
res = inv.Hybrid(30,.917,air_gap=95,uncertainty = .15) | ||
|
||
# print the identified parameters | ||
print(res) | ||
|
||
# Plot the absorption curves using the actual parameters vs those identified from the Indirect method | ||
inv.plot_comparison(res) | ||
|
||
res >>> {'thickness': 29.982, | ||
'flow resistivity': 46209.81, | ||
'porosity': 0.918, | ||
'tortuosity': 2.103, | ||
'viscous characteristic length': 83.0, | ||
'thermal characteristic length': 128.0, | ||
'air gap': 100.0, | ||
'error': 1.3018228618069009e-17} | ||
``` | ||
|
||
<br></br> | ||
|
||
![](../assets/ex_material_identification_hybrid.png) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
# Indirect Characterization | ||
Use an indirect characterization method to identify parameters of the Johnson-Champaux-Allard model given data obtained from an impedance tube. | ||
|
||
```python | ||
from acoustipy import AcousticTMM, AcousticID | ||
|
||
# Create an AcousticTMM object to generate toy impedance tube data | ||
structure = AcousticTMM(incidence='Normal',air_temperature = 20) | ||
|
||
# Define the JCA and air gap material parameters for the toy data | ||
layer1 = structure.Add_JCA_Layer(30, 46182,.917,2.1,83,128) | ||
air = structure.Add_Air_Layer(thickness = 100) | ||
|
||
# Generate rigid backed reflection data and save to a csv file | ||
s1 = structure.assemble_structure(layer1) | ||
A1 = structure.reflection(s1) | ||
structure.to_csv('no_gap',A1) | ||
|
||
# Generate air backed reflection data and save to a csv file | ||
s2 = structure.assemble_structure(layer1,air) | ||
A2 = structure.reflection(s2) | ||
structure.to_csv('gap',A2) | ||
|
||
# Create an AcousticID object, specifying to mount types, data files, and data types | ||
inv = AcousticID(mount_type='Dual',no_gap_file="no_gap.csv",gap_file = "gap.csv",air_temperature=20,input_type='reflection') | ||
|
||
# Call the Indirect method to find the flow resistivity, tortuosity, and viscous, and thermal characteristic lengths of the material | ||
res = inv.Indirect(30,.917,air_gap=100) | ||
|
||
# Plot the absorption curves using the actual parameters vs those identified from the Indirect method | ||
inv.plot_comparison(res) | ||
|
||
# print the identified parameters | ||
print(res) | ||
|
||
res >> {'thickness': 30, | ||
'flow resistivity': 46182.79193470273, | ||
'porosity': 0.9326784023844896, | ||
'tortuosity': 2.1373594528548225, | ||
'viscous characteristic length': 83.16500367154856, | ||
'thermal characteristic length': 115.12539138619321, | ||
'air gap': 100} | ||
|
||
``` | ||
|
||
<br></br> | ||
|
||
![](../assets/ex_material_identification_indirect.png) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
# Inverse JCA Characterization | ||
Use an inverse characterization method to identify parameters of the Johnson-Champaux-Allard model given data obtained from an impedance tube. | ||
|
||
```python | ||
from acoustipy import acousticTMM, AcousticID | ||
|
||
# Create an AcousticTMM object to generate toy impedance tube data | ||
structure = acousticTMM(incidence='Normal',air_temperature = 20) | ||
|
||
# Define the JCA and air gap material parameters for the toy data | ||
layer1 = structure.Add_JCA_Layer(thickness = 30, flow_resistivity = 46879, porosity = .93, tortuosity = 1.7, viscous_characteristic_length = 80, thermal_characteristic_length = 105) | ||
air = structure.Add_Air_Layer(thickness = 375) | ||
|
||
# Generate rigid backed absorption data and save to a csv file | ||
s1 = structure.assemble_structure(layer1) | ||
A1 = structure.absorption(s1) | ||
structure.to_csv('no_gap',A1) | ||
|
||
# Generate air backed absorption data and save to a csv file | ||
s2 = structure.assemble_structure(layer1,air) | ||
A2 = structure.absorption(s2) | ||
structure.to_csv('gap',A2) | ||
|
||
# Create an AcousticID object, specifying to mount types, data files, and data types | ||
inv = AcousticID(mount_type='Dual',no_gap_file="no_gap.csv", gap_file = 'gap.csv',air_temperature=20,input_type='absorption') | ||
|
||
# Call the Inverse method to find the tortuosity, viscous, and thermal characteristic lengths of the material | ||
res = inv.Inverse(30, 47000,.926,air_gap=375,uncertainty=.2,verbose=True) | ||
|
||
# Display summary statistics about the optimization | ||
stats = inv.stats(res) | ||
print(stats) | ||
|
||
# Plot the results of the found parameters compared to the toy input data | ||
inv.plot_comparison(res) | ||
|
||
# Save the optimization results to a csv | ||
inv.to_csv("params.csv",res) | ||
|
||
stats = {'slope': 1.000037058594857, 'intercept': 9.276088883464206e-05, 'r_value': 0.9999999674493408, 'p_value': 0.0, 'std_err': 8.732362148426126e-06} | ||
``` | ||
|
||
<br></br> | ||
|
||
![](../assets/ex_material_identification_inverse.png) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
# Using impedance tube data | ||
Estimate the diffuse sound field absorption coefficients of a structure | ||
using the normal incidence reflection coefficients obtained via impedance | ||
tube. | ||
|
||
```python | ||
from acoustipy import AcousticTMM | ||
|
||
# Generate synthetic "impedance tube" data | ||
structure = AcousticTMM(incidence='Normal', air_temperature = 20) | ||
|
||
# Define the JCA and air gap material parameters for the synthetic data | ||
layer1 = structure.Add_JCA_Layer(25.4, 60000, .91, 1.3, 85, 110) | ||
air = structure.Add_Air_Layer(thickness = 100) | ||
|
||
# Generate rigid backed reflection data and save to a csv file | ||
s1 = structure.assemble_structure(layer1) | ||
r1 = structure.reflection(s1) | ||
structure.to_csv('no_gap_tube',r1) | ||
|
||
# Generate air backed absorption data and save to a csv file | ||
s2 = structure.assemble_structure(layer1,air) | ||
r2 = structure.reflection(s2) | ||
structure.to_csv('gap_tube',r2) | ||
|
||
# Create a new structure to estimate the diffuse field absorption coefficients | ||
estimated_structure = AcousticTMM(incidence='Diffuse', air_temperature = 20) | ||
|
||
# Load the synthetic impedance tube data and define a new air layer | ||
estimated_layer = estimated_structure.Add_Layer_From_Tube(no_gap_file = 'no_gap_tube.csv', gap_file='gap_tube.csv', sample_thickness=25.4, air_gap_thickness=100) | ||
air2 = estimated_structure.Add_Air_Layer(thickness = 400) | ||
|
||
# Generate narrow band absorption data for the new structure | ||
s3 = estimated_structure.assemble_structure(estimated_layer,air2) | ||
absorption = structure.absorption(s3) | ||
|
||
# Calculate the 3rd octave bands absorption coefficients | ||
bands = structure.octave_bands(absorption) | ||
|
||
# Calculate the four frequency average absorption | ||
ffa_estimate = structure.FFA(bands) | ||
print(ffa_estimate) | ||
|
||
>>> 0.717 | ||
|
||
# Compare the estimated FFA to that calculated from the original layer data | ||
air3 = structure.Add_Air_Layer(thickness = 400) | ||
s4 = structure.assemble_structure(layer1,air3) | ||
abs1 = structure.absorption(s4) | ||
bands1 = structure.octave_bands(abs1) | ||
ffa_original = structure.FFA(bands1) | ||
print(ffa_original) | ||
|
||
>>> 0.717 | ||
``` | ||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
# Saving layers to a database | ||
Save the parameters of individual layers to a built-in SQLite database. | ||
|
||
```python | ||
from acoustipy import AcousticTMM, AcoustiBase | ||
|
||
|
||
structure = AcousticTMM(incidence='Normal',air_temperature = 20) | ||
|
||
# For each Add_XXX_Layer method, enable the save_layer parameter and give it a unique layer name | ||
db = structure.Add_DB_Layer(25.4, 50000,save_layer=True,layer_name='test_DB') | ||
dbm = structure.Add_DBM_Layer(25.4, 50000,save_layer=True,layer_name='test_DBM') | ||
jca = structure.Add_JCA_Layer(25.4, 50000,.90,1.2,80,110,save_layer=True,layer_name='test_JCA') | ||
jcal = structure.Add_JCAL_Layer(25.4, 50000,.90,1.2,80,110,50,save_layer=True,layer_name='test_JCAL') | ||
jcapl = structure.Add_JCAPL_Layer(25.4, 50000, .90, 1.2, 80, 110, 50, 70, 65,save_layer=True,layer_name='test_JCAPL') | ||
horoshenkov = structure.Add_Horoshenkov_Layer(40, .90, 147, .325, save_layer=True, layer_name='test_horoshenkov') | ||
biot_limp = structure.Add_Biot_Limp_Layer('JCA',25.4, 50000,200, .90, 1.2, 80, 110,save_layer=True,layer_name='test_biot_limp') | ||
biot_rigid = structure.Add_Biot_Rigid_Layer('JCA',25.4, 50000,200, .90, 1.2, 80, 110,save_layer=True,layer_name='test2_biot_rigid') | ||
screen = structure.Add_Resistive_Screen(2.54, 50000, .90,save_layer=True,layer_name='test_screen') | ||
maa = structure.Add_MAA_MPP_Layer(2.54, .5, 1,save_layer=True,layer_name='test_maa_mpp') | ||
ef_mpp = structure.Add_MPP_EF_Layer(2.54, .5, 1,save_layer=True,layer_name='test_ef_mpp') | ||
|
||
# Pull the layer information from the database and save to a .csv file | ||
s = AcoustiBase() | ||
s.summarize_layers() | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
# Load layers from a database | ||
Load the previously saved layers from the database and calculate the transmission loss | ||
of one of the layers. | ||
|
||
```python | ||
from acoustipy import AcousticTMM | ||
|
||
structure = AcousticTMM(incidence='Normal',air_temperature = 20) | ||
|
||
# Add layers from the database | ||
db = structure.Add_Layer_From_Database('test_DB') | ||
dbm = structure.Add_Layer_From_Database('test_DBM') | ||
jca = structure.Add_Layer_From_Database('test_JCA') | ||
jcal = structure.Add_Layer_From_Database('test_JCAL') | ||
jcapl = structure.Add_Layer_From_Database('test_JCAPL') | ||
horoshenkov = structure.Add_Layer_From_Database('test_horoshenkov') | ||
biot_limp = structure.Add_Layer_From_Database('test_biot_limp') | ||
biot_rigid = structure.Add_Layer_From_Database('test2_biot_rigid') | ||
screen = structure.Add_Layer_From_Database('test_screen') | ||
maa = structure.Add_Layer_From_Database('test_maa_mpp') | ||
ef_mpp = structure.Add_Layer_From_Database('test_ef_mpp') | ||
|
||
# Calculate th narrow band transmission coefficients for the JCA layer | ||
s = structure.assemble_structure(jca) | ||
tl = structure.transmission_loss(s) | ||
|
||
# Plot the transmission coefficients | ||
structure.plot_curve([tl]) | ||
``` | ||
<br> | ||
|
||
![](../assets/ex_layers_from_database.png) |
Oops, something went wrong.