How can I extract or manipulate data form a harmonic response frequency response
Hi all, I am a first-time user of PyDPF and currently have a harmonic response simulation I have run. In my post-processing, I have a frequency response graph that I would like to extract the data from the acceleration amplitude across all the frequencies in my harmonic response. This data is in my frequency response under solution in mechanical is there a way to extract this data into numpy arrays so I can multiply it by a factor to and replot it myself
Best Answer
-
Hi thnak you all for the comments I was able to solve the problem just calling acceleration even though it does not show in the available results when print the model
(Msup analysis
Unit system: NMM: mm, ton, N, s, mA, degC
Physics Type: Mechanical
Available results:
- displacement: Nodal Displacement
- reaction_force: Nodal Force
- stress: ElementalNodal Stress
- elemental_volume: Elemental Volume
- stiffness_matrix_energy: Elemental Energy-stiffness matrix
- artificial_hourglass_energy: Elemental Hourglass Energy
- thermal_dissipation_energy: Elemental thermal dissipation energy
- kinetic_energy: Elemental Kinetic Energy
- co_energy: Elemental co-energy
- incremental_energy: Elemental incremental energy
- elastic_strain: ElementalNodal Strain)I am still able to call and use it then using the operators and .data () I was able to get my data in dpf arrays that I could do whatever I wanted to with them
a_op = ops.result.acceleration_Y(time_scoping=time_ids)
a_op.inputs.data_sources.connect(datasource)
my_a = a_op.outputs.fields_container()
_op = dpf.operators.math.amplitude_fc() # Operator instantiation
a_op.inputs.fields_container.connect(my_a)
a_op_field = a_op.outputs.fields_container()
a_max = max(a_op_field[i].data)above example of what I kind of had to do to get my required data in format I wanted to work with.
0
Answers
-
Take a look at the PyDPF examples in the documentation.
What you want to do seems generally generic. You can use the displacement operator in conjunction with the amplitude operator to combine real and img. components.You can then use general math operators to scale the fields by whatever constants you want instead of using numpy. You can use numpy as well, but DPF operators can do the same.
0 -
Let's assume you have a dictionary named frequency_response where the data is stored. The dictionary may look something like this:
frequency_response = {
'frequencies': [f1, f2, f3, ...],
'acceleration_amplitudes': [amp1, amp2, amp3, ...],
# other relevant data...
}Here's how you might extract the data and manipulate it using numpy:
import numpy as npExtract data from the dictionary
frequencies = frequency_response['frequencies']
acceleration_amplitudes = frequency_response['acceleration_amplitudes']Convert lists to numpy arrays
freq_array = np.array(frequencies)
amp_array = np.array(acceleration_amplitudes)Multiply the amplitude array by a factor
factor = 2.0
scaled_amp_array = factor * amp_arrayNow, you can use the numpy arrays for further processing or plotting the company info API.
0