Davout 0.1.1.dev181__py3-none-any.whl → 0.1.1.dev182__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- Davout/DeepMech/aa_tests/SVD_framework/dataset_generator.py +62 -13
- Davout/DeepMech/aa_tests/SVD_framework/input_data_filler.py +13 -11
- Davout/DeepMech/aa_tests/SVD_framework/kinematics_surrogate_model.py +53 -26
- Davout/DeepMech/tool_box/gpu_tools.py +21 -0
- Davout/GraphUtilities/aa_tests/linear_transformation_plot.py +165 -0
- {davout-0.1.1.dev181.dist-info → davout-0.1.1.dev182.dist-info}/METADATA +1 -1
- {davout-0.1.1.dev181.dist-info → davout-0.1.1.dev182.dist-info}/RECORD +10 -8
- {davout-0.1.1.dev181.dist-info → davout-0.1.1.dev182.dist-info}/WHEEL +0 -0
- {davout-0.1.1.dev181.dist-info → davout-0.1.1.dev182.dist-info}/licenses/LICENSE +0 -0
- {davout-0.1.1.dev181.dist-info → davout-0.1.1.dev182.dist-info}/top_level.txt +0 -0
|
@@ -14,6 +14,8 @@ from .....Davout.DeepMech.aa_tests.mecsol_2026_quotient_space.box_with_imposed_d
|
|
|
14
14
|
|
|
15
15
|
from .....Davout.DeepMech.aa_tests.mecsol_2026_quotient_space.young_modulus_field_generator import generate_field
|
|
16
16
|
|
|
17
|
+
from input_data_filler import fill_load_steps
|
|
18
|
+
|
|
17
19
|
import numpy as np
|
|
18
20
|
|
|
19
21
|
import traceback
|
|
@@ -26,7 +28,8 @@ def generate_dataset(n_samples, limits_list, p_norm_list, results_path,
|
|
|
26
28
|
displacement_file_name, young_modulus_file, mesh_file_name, cube_size,
|
|
27
29
|
influence_radius, damping_factor, radius_power, mesh_data_class,
|
|
28
30
|
lagrange_multiplier_file_name, strain_energy_file_name,
|
|
29
|
-
|
|
31
|
+
displacement_matrix_file_name, strain_energy_matrix_file_name,
|
|
32
|
+
input_matrix_file_name, save_snapshot_displacement=False):
|
|
30
33
|
|
|
31
34
|
# Initializes the list of samples
|
|
32
35
|
|
|
@@ -193,14 +196,14 @@ save_snapshot_displacement=False):
|
|
|
193
196
|
|
|
194
197
|
# Saves the lists into binary and txt files
|
|
195
198
|
|
|
196
|
-
np.save(results_path+"//
|
|
197
|
-
|
|
199
|
+
np.save(results_path+"//"+displacement_matrix_file_name,
|
|
200
|
+
np.array(succesful_displacement))
|
|
198
201
|
|
|
199
|
-
np.save(results_path+"//
|
|
200
|
-
|
|
202
|
+
np.save(results_path+"//"+strain_energy_matrix_file_name,
|
|
203
|
+
np.array(succesful_strain_energy))
|
|
201
204
|
|
|
202
|
-
np.save(results_path+"//
|
|
203
|
-
|
|
205
|
+
np.save(results_path+"//"+input_matrix_file_name, np.array(
|
|
206
|
+
succesful_data))
|
|
204
207
|
|
|
205
208
|
list_toTxt(completed_simulations, "00_completed_simulations",
|
|
206
209
|
parent_path=results_path)
|
|
@@ -372,6 +375,31 @@ if __name__=="__main__":
|
|
|
372
375
|
|
|
373
376
|
mesh_file_name = "box_mesh_mecsol"
|
|
374
377
|
|
|
378
|
+
# Sets the file name of the data matrices
|
|
379
|
+
|
|
380
|
+
displacement_matrix_file_name = ("00_successful_displacement_matri"+
|
|
381
|
+
"x.npy")
|
|
382
|
+
|
|
383
|
+
strain_energy_matrix_file_name = ("00_successful_strain_energy_mat"+
|
|
384
|
+
"rix.npy")
|
|
385
|
+
|
|
386
|
+
input_matrix_file_name = "00_successful_data_matrix.npy"
|
|
387
|
+
|
|
388
|
+
# Sets the file names of the completed (filled-in with load-steps)
|
|
389
|
+
# data matrices and the filtered counterpart
|
|
390
|
+
|
|
391
|
+
complete_data_matrix_file_name = ("00_successful_complete_data_mat"+
|
|
392
|
+
"rix.npy")
|
|
393
|
+
|
|
394
|
+
complete_and_filtered_data_matrix_file_name = ("00_successful_comp"+
|
|
395
|
+
"lete_and_filtered_data_matrix.npy")
|
|
396
|
+
|
|
397
|
+
# Sets the initial and final time points for the simulation
|
|
398
|
+
|
|
399
|
+
initial_time = 0.2
|
|
400
|
+
|
|
401
|
+
final_time = 1.0
|
|
402
|
+
|
|
375
403
|
# Constructs the mesh
|
|
376
404
|
|
|
377
405
|
mesh_data_class = read_mshMesh({"length x": cube_size, "length y":
|
|
@@ -382,10 +410,31 @@ if __name__=="__main__":
|
|
|
382
410
|
"bias x": ["Bump", bias_factor], "bias y": ["Bump", bias_factor],
|
|
383
411
|
"bias z": ["Bump", bias_factor]})
|
|
384
412
|
|
|
385
|
-
#
|
|
413
|
+
# Defines a flag fo generating the dataset and another flag for ge-
|
|
414
|
+
# nerating the dataset with the intermediate load steps and its fil-
|
|
415
|
+
# tered version as well
|
|
416
|
+
|
|
417
|
+
flag_generate_dataset = False
|
|
418
|
+
|
|
419
|
+
flag_fill_in_load_steps = True
|
|
420
|
+
|
|
421
|
+
# Generates the dataset from skretch
|
|
422
|
+
|
|
423
|
+
if flag_generate_dataset:
|
|
424
|
+
|
|
425
|
+
generate_dataset(n_samples, limits_list, p_norm_list,
|
|
426
|
+
results_path, displacement_file_name, young_modulus_file,
|
|
427
|
+
mesh_file_name, cube_size, influence_radius, damping_factor,
|
|
428
|
+
radius_power, mesh_data_class, lagrange_multiplier_file_name,
|
|
429
|
+
strain_energy_file_name, displacement_matrix_file_name,
|
|
430
|
+
strain_energy_matrix_file_name, input_matrix_file_name,
|
|
431
|
+
save_snapshot_displacement=False)
|
|
432
|
+
|
|
433
|
+
# Fills the load-steps and generates the filtered dataset from it
|
|
434
|
+
|
|
435
|
+
if flag_fill_in_load_steps:
|
|
386
436
|
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
save_snapshot_displacement=False)
|
|
437
|
+
fill_load_steps(input_matrix_file_name,
|
|
438
|
+
displacement_matrix_file_name, complete_data_matrix_file_name,
|
|
439
|
+
complete_and_filtered_data_matrix_file_name, results_path,
|
|
440
|
+
initial_time, final_time)
|
|
@@ -60,10 +60,10 @@ final_time):
|
|
|
60
60
|
|
|
61
61
|
# Recovers the displacement gradient
|
|
62
62
|
|
|
63
|
-
displacement_gradient = np.array([[sample_data[
|
|
64
|
-
sample_data[
|
|
65
|
-
sample_data[
|
|
66
|
-
sample_data[
|
|
63
|
+
displacement_gradient = np.array([[sample_data[0],
|
|
64
|
+
sample_data[1], sample_data[2]], [sample_data[3],
|
|
65
|
+
sample_data[4], sample_data[5]], [sample_data[6],
|
|
66
|
+
sample_data[7], sample_data[8]]])
|
|
67
67
|
|
|
68
68
|
# Gets the corresponding deformation gradient
|
|
69
69
|
|
|
@@ -118,7 +118,7 @@ final_time):
|
|
|
118
118
|
new_disp_grad[0,1], new_disp_grad[0,2], new_disp_grad[
|
|
119
119
|
1,0], new_disp_grad[1,1], new_disp_grad[1,2],
|
|
120
120
|
new_disp_grad[2,0], new_disp_grad[2,1], new_disp_grad[
|
|
121
|
-
2,2], sample_data[
|
|
121
|
+
2,2], sample_data[9], sample_data[10]])
|
|
122
122
|
|
|
123
123
|
# Adds this sample to the filtered input data. Inserts
|
|
124
124
|
# the load-based data as the first columns, since this
|
|
@@ -137,18 +137,20 @@ final_time):
|
|
|
137
137
|
new_input_list = np.array(new_input_list)
|
|
138
138
|
|
|
139
139
|
print("The new input data matrix has shape "+str(
|
|
140
|
-
new_input_list.shape)+", whereas it had "+str(
|
|
141
|
-
|
|
142
|
-
" has "+str(displacement_matrix.shape
|
|
140
|
+
new_input_list.shape)+", whereas it had the shape "+str(
|
|
141
|
+
input_data.shape)+" before.\nThe displacement matrix, on the o"+
|
|
142
|
+
"ther hand, has shape equal to "+str(displacement_matrix.shape)+
|
|
143
|
+
"\n")
|
|
143
144
|
|
|
144
145
|
np.save(results_path+"//"+new_input_file, new_input_list)
|
|
145
146
|
|
|
146
147
|
new_filtered_input_list = np.array(new_filtered_input_list)
|
|
147
148
|
|
|
148
149
|
print("The new filtered input data matrix has shape "+str(
|
|
149
|
-
new_filtered_input_list.shape)+", whereas it had "+str(
|
|
150
|
-
input_data.shape
|
|
151
|
-
"
|
|
150
|
+
new_filtered_input_list.shape)+", whereas it had the shape "+str(
|
|
151
|
+
input_data.shape)+" before.\nThe displacement matrix, on th"+
|
|
152
|
+
"e other hand, has shape equal to "+str(displacement_matrix.shape
|
|
153
|
+
)+"\n")
|
|
152
154
|
|
|
153
155
|
np.save(results_path+"//"+new_filtered_input_file,
|
|
154
156
|
new_filtered_input_list)
|
|
@@ -5,6 +5,10 @@ import numpy as np
|
|
|
5
5
|
|
|
6
6
|
import tensorflow as tf
|
|
7
7
|
|
|
8
|
+
from .....Davout.DeepMech.tool_box.gpu_tools import give_access_of_gpu_to_tensorflow
|
|
9
|
+
|
|
10
|
+
give_access_of_gpu_to_tensorflow(True)
|
|
11
|
+
|
|
8
12
|
from time import time
|
|
9
13
|
|
|
10
14
|
from .....Davout.DeepMech.tool_box import ANN_tools, training_tools
|
|
@@ -28,8 +32,7 @@ class RVEKinematicsSurrogateModel:
|
|
|
28
32
|
maximum_training_iterations, verbose_delta_iterations,
|
|
29
33
|
mesh_file_name, optimizer, subdofs_to_learn, parameters_dtype="flo"+
|
|
30
34
|
"at32", householder_epsilon=1.0, verbose=True, integer_dtype="int3"+
|
|
31
|
-
"2",
|
|
32
|
-
non_orthogonal_matrices=False, device_type="CPU",
|
|
35
|
+
"2", non_orthogonal_matrices=False, device_type="CPU",
|
|
33
36
|
input_data_regularization_method=None):
|
|
34
37
|
|
|
35
38
|
# Saves the needed information
|
|
@@ -38,9 +41,6 @@ class RVEKinematicsSurrogateModel:
|
|
|
38
41
|
|
|
39
42
|
self.device_type = device_type
|
|
40
43
|
|
|
41
|
-
self.get_all_inputs_to_zeroth_order_of_magnitude = (
|
|
42
|
-
get_all_inputs_to_zeroth_order_of_magnitude)
|
|
43
|
-
|
|
44
44
|
self.activations_list_main_network = activations_list_main_network
|
|
45
45
|
|
|
46
46
|
self.activations_list_auxiliar_network = (
|
|
@@ -89,7 +89,7 @@ class RVEKinematicsSurrogateModel:
|
|
|
89
89
|
# Converts the tensor of DOFs to a tensorflow integer tensor
|
|
90
90
|
|
|
91
91
|
self.subdofs_to_learn = tf.convert_to_tensor(subdofs_to_learn,
|
|
92
|
-
dtype=tf.as_dtype(self.
|
|
92
|
+
dtype=tf.as_dtype(self.integer_dtype))
|
|
93
93
|
|
|
94
94
|
# Gets the number of output neurons from the tensor of the indi-
|
|
95
95
|
# ces of the DOFs that will actually be learnt
|
|
@@ -98,13 +98,31 @@ class RVEKinematicsSurrogateModel:
|
|
|
98
98
|
|
|
99
99
|
# Reads the output data
|
|
100
100
|
|
|
101
|
-
self.
|
|
101
|
+
self.whole_output_data = np.load(self.results_path+"//"+
|
|
102
102
|
self.displacement_data_file)
|
|
103
103
|
|
|
104
104
|
# Gets the numbers of samples and of total of DOFs
|
|
105
105
|
|
|
106
106
|
self.number_of_samples, self.total_number_of_dofs = (
|
|
107
|
-
self.
|
|
107
|
+
self.whole_output_data.shape)
|
|
108
|
+
|
|
109
|
+
# Checks whether subdofs to learn has any DOF index that is lar-
|
|
110
|
+
# ger than the number of DOFs of the output data
|
|
111
|
+
|
|
112
|
+
if tf.reduce_max(self.subdofs_to_learn).numpy(
|
|
113
|
+
)>=self.total_number_of_dofs:
|
|
114
|
+
|
|
115
|
+
raise IndexError("The maximum DOF index requested by 'subd"+
|
|
116
|
+
"ofs_to_learn' is "+str(tf.reduce_max(self.subdofs_to_learn
|
|
117
|
+
).numpy())+". But the output data at\n"+str(
|
|
118
|
+
self.results_path+"//"+self.displacement_data_file)+"\nhas"+
|
|
119
|
+
" only "+str(self.total_number_of_dofs)+" columns")
|
|
120
|
+
|
|
121
|
+
# Otherwise, uses the subdofs to learn to retrieve the needed
|
|
122
|
+
# DOFs for training
|
|
123
|
+
|
|
124
|
+
self.output_data = self.whole_output_data[:,
|
|
125
|
+
self.subdofs_to_learn]
|
|
108
126
|
|
|
109
127
|
# Gets the input data
|
|
110
128
|
|
|
@@ -343,9 +361,19 @@ class RVEKinematicsSurrogateModel:
|
|
|
343
361
|
|
|
344
362
|
if __name__=="__main__":
|
|
345
363
|
|
|
364
|
+
# Sets the number of transfinite divisions in the RVE mesh
|
|
365
|
+
|
|
366
|
+
n_divisions = 6
|
|
367
|
+
|
|
368
|
+
# Sets a dictionary for the number of DOFs in the mesh for each num-
|
|
369
|
+
# ber of divisions
|
|
370
|
+
|
|
371
|
+
dofs_per_number_of_divisions = {6: 3993, 8: 10125, 10: 20577}
|
|
372
|
+
|
|
346
373
|
# Defines the array with the DOFs to be learnt
|
|
347
374
|
|
|
348
|
-
subdofs_to_learn = np.arange(0,
|
|
375
|
+
subdofs_to_learn = np.arange(0, dofs_per_number_of_divisions[
|
|
376
|
+
n_divisions], 3)
|
|
349
377
|
|
|
350
378
|
# Defines the number of input neurons of the main network. Remember
|
|
351
379
|
# that the data matrix is a tensor [n_samples, n_input_variables].
|
|
@@ -358,7 +386,7 @@ if __name__=="__main__":
|
|
|
358
386
|
# Defines the number of neurons of the different hidden layers and of
|
|
359
387
|
# the output layer
|
|
360
388
|
|
|
361
|
-
n_neurons_per_layer = [100, 1000,
|
|
389
|
+
n_neurons_per_layer = [100, 1000, subdofs_to_learn.shape[0]]
|
|
362
390
|
|
|
363
391
|
# Sets a list of layers and the activation functions
|
|
364
392
|
|
|
@@ -366,11 +394,12 @@ if __name__=="__main__":
|
|
|
366
394
|
n_neurons_per_layer[0]}}, {"elu": {"number of neurons":
|
|
367
395
|
n_neurons_per_layer[1]}}, {"linear": n_neurons_per_layer[2]}]
|
|
368
396
|
|
|
369
|
-
activations_list_auxiliar_network = [{"quadratic": {"number"+
|
|
370
|
-
"
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
397
|
+
activations_list_auxiliar_network = [{"quadratic": {"number of neu"+
|
|
398
|
+
"rons": min(quotient_space_dimension, n_neurons_per_layer[0]), "a2":
|
|
399
|
+
1.0}},
|
|
400
|
+
{"quadratic": {"number of neurons": min(n_neurons_per_layer[0],
|
|
401
|
+
n_neurons_per_layer[1]), "a2": 1.0}},
|
|
402
|
+
{"quadratic": {"number of neurons": min(n_neurons_per_layer[1],
|
|
374
403
|
n_neurons_per_layer[2])}}]
|
|
375
404
|
|
|
376
405
|
# Sets the modulating function for the weights matrices
|
|
@@ -395,13 +424,17 @@ if __name__=="__main__":
|
|
|
395
424
|
|
|
396
425
|
loss_metric = "MeanSquaredError"
|
|
397
426
|
|
|
427
|
+
loss_metric = {"name": "LpNormError", "p": 12, "use_stable_impleme"+
|
|
428
|
+
"ntation": True}
|
|
429
|
+
|
|
398
430
|
parameters_dtype = "float32"
|
|
399
431
|
|
|
400
432
|
saved_model_file = "RVE_kinematics_model.keras"
|
|
401
433
|
|
|
402
434
|
# Sets the path for the data
|
|
403
435
|
|
|
404
|
-
results_path = get_parent_path_of_file()+"//
|
|
436
|
+
results_path = (get_parent_path_of_file()+"//results_n_divisions_"+
|
|
437
|
+
str(n_divisions))
|
|
405
438
|
|
|
406
439
|
displacement_data_file = "00_successful_displacement_matrix.npy"
|
|
407
440
|
|
|
@@ -411,12 +444,8 @@ if __name__=="__main__":
|
|
|
411
444
|
|
|
412
445
|
# Sets the method to regularize the input data matrix
|
|
413
446
|
|
|
414
|
-
input_data_regularization_method =
|
|
415
|
-
|
|
416
|
-
# Sets if the input data must be put into the same order of magnitu-
|
|
417
|
-
# de
|
|
418
|
-
|
|
419
|
-
get_all_inputs_to_zeroth_order_of_magnitude = False
|
|
447
|
+
input_data_regularization_method = ("maximum_absolute_order_normal"+
|
|
448
|
+
"ization")
|
|
420
449
|
|
|
421
450
|
# Sets the device type where the training will be performed
|
|
422
451
|
|
|
@@ -425,7 +454,7 @@ if __name__=="__main__":
|
|
|
425
454
|
# Sets whether the constraint on orthogonality of the SVD matrices
|
|
426
455
|
# will not be enforced
|
|
427
456
|
|
|
428
|
-
non_orthogonal_matrices =
|
|
457
|
+
non_orthogonal_matrices = True
|
|
429
458
|
|
|
430
459
|
# Instantiates the class that owns all information about training
|
|
431
460
|
# and testing models
|
|
@@ -438,9 +467,7 @@ if __name__=="__main__":
|
|
|
438
467
|
n_best_models, n_best_samples, maximum_training_iterations,
|
|
439
468
|
verbose_delta_iterations, mesh_file_name, optimizer,
|
|
440
469
|
subdofs_to_learn, parameters_dtype=parameters_dtype,
|
|
441
|
-
householder_epsilon=1.0, verbose=True,
|
|
442
|
-
get_all_inputs_to_zeroth_order_of_magnitude=
|
|
443
|
-
get_all_inputs_to_zeroth_order_of_magnitude, device_type=
|
|
470
|
+
householder_epsilon=1.0, verbose=True, device_type=
|
|
444
471
|
device_type, non_orthogonal_matrices=non_orthogonal_matrices,
|
|
445
472
|
input_data_regularization_method=input_data_regularization_method)
|
|
446
473
|
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
# Routine to store methods to set the GPU for tensorflow
|
|
2
|
+
|
|
3
|
+
import tensorflow as tf
|
|
4
|
+
|
|
5
|
+
# Defines a function to set the access of tensorflow to the GPU
|
|
6
|
+
|
|
7
|
+
def give_access_of_gpu_to_tensorflow(flag_to_use_gpu):
|
|
8
|
+
|
|
9
|
+
# Checks whether the flag for tensorflow to use the GPU is false
|
|
10
|
+
|
|
11
|
+
if not flag_to_use_gpu:
|
|
12
|
+
|
|
13
|
+
# Disables the GPU if necessary
|
|
14
|
+
|
|
15
|
+
tf.config.set_visible_devices([], 'GPU')
|
|
16
|
+
|
|
17
|
+
print(tf.config.list_physical_devices('CPU'))
|
|
18
|
+
|
|
19
|
+
print(tf.config.list_physical_devices('GPU'))
|
|
20
|
+
|
|
21
|
+
print("Visible GPUs:", tf.config.get_visible_devices("GPU"))
|
|
@@ -0,0 +1,165 @@
|
|
|
1
|
+
# Routine to plot the result of a linear transformation applied to vec-
|
|
2
|
+
# tors in the origin-centered circumference of the XY plane
|
|
3
|
+
|
|
4
|
+
import numpy as np
|
|
5
|
+
|
|
6
|
+
from ....Davout.GraphUtilities.plotting_tools import plane_plot
|
|
7
|
+
|
|
8
|
+
# Defines a function to plot the 2D transformation.
|
|
9
|
+
# 'column_eigenvectors_array' is a [2,2] numpy array, where the columns
|
|
10
|
+
# are the column eigenvectors.
|
|
11
|
+
# 'eigenvalues_array' is a [2] numpy array, where each row is the eigen-
|
|
12
|
+
# value to the corresponding eigenvector
|
|
13
|
+
|
|
14
|
+
def generate_linear_2D_transformation(column_eigenvectors_array,
|
|
15
|
+
eigenvalues_array, p=2, n_points=300):
|
|
16
|
+
|
|
17
|
+
print("The original eigenvectors are:\n"+str(
|
|
18
|
+
column_eigenvectors_array)+"\n")
|
|
19
|
+
|
|
20
|
+
# Normalizes the eigenvectors
|
|
21
|
+
|
|
22
|
+
eigenvectors_norms = np.linalg.norm(column_eigenvectors_array,
|
|
23
|
+
axis=0)
|
|
24
|
+
|
|
25
|
+
column_eigenvectors_array = (column_eigenvectors_array/
|
|
26
|
+
eigenvectors_norms)
|
|
27
|
+
|
|
28
|
+
print("The normalized eigenvectors are:\n"+str(
|
|
29
|
+
column_eigenvectors_array)+"\n")
|
|
30
|
+
|
|
31
|
+
# Gets the polar angles of the eigenvectors
|
|
32
|
+
|
|
33
|
+
polar_angles = np.arctan2(column_eigenvectors_array[1,:],
|
|
34
|
+
column_eigenvectors_array[0,:])
|
|
35
|
+
|
|
36
|
+
# Makes sure they are in the first polar cycle
|
|
37
|
+
|
|
38
|
+
polar_angles = np.mod(polar_angles, 2.0*np.pi)
|
|
39
|
+
|
|
40
|
+
# Makes sure the first polar angle is lower than the second one
|
|
41
|
+
|
|
42
|
+
polar_angle_1, polar_angle_2 = np.sort(polar_angles)
|
|
43
|
+
|
|
44
|
+
# Gets the indices of precedence of the eigenvectors
|
|
45
|
+
|
|
46
|
+
eigenvector_polar_indices = np.argsort(polar_angles)
|
|
47
|
+
|
|
48
|
+
print("Polar angle of the first eigenvector: "+str(polar_angle_1*(
|
|
49
|
+
180.0/np.pi))+" degrees or "+str(polar_angle_1)+" radians\nPolar a"+
|
|
50
|
+
"ngle of the second eigenvector: "+str(polar_angle_2*(180.0/np.pi))+
|
|
51
|
+
" degrees or "+str(polar_angle_2)+" radians\n")
|
|
52
|
+
|
|
53
|
+
# Computes the inverse of the eigenvectors matrix
|
|
54
|
+
|
|
55
|
+
eigenvectors_inverse = np.linalg.inv(column_eigenvectors_array)
|
|
56
|
+
|
|
57
|
+
print("The inverse of the matrix of eigenvectors is:\n"+str(
|
|
58
|
+
eigenvectors_inverse)+"\n")
|
|
59
|
+
|
|
60
|
+
# Reconstructs the transformation matrix using the spectral decompo-
|
|
61
|
+
# sition
|
|
62
|
+
|
|
63
|
+
print("The diagonal format of the transformation matrix is: "+str(
|
|
64
|
+
np.diag(eigenvalues_array))+"\n")
|
|
65
|
+
|
|
66
|
+
transformation_matrix = np.einsum('ij,jl,lk->ik',
|
|
67
|
+
column_eigenvectors_array, np.diag(eigenvalues_array),
|
|
68
|
+
eigenvectors_inverse)
|
|
69
|
+
|
|
70
|
+
print("The transformation matrix is:\n"+str(transformation_matrix)+
|
|
71
|
+
"\n")
|
|
72
|
+
|
|
73
|
+
# Checks the eigenvalues and eigenvectors
|
|
74
|
+
|
|
75
|
+
_, eigenvectors = np.linalg.eig(transformation_matrix)
|
|
76
|
+
|
|
77
|
+
print("The eigenvalues and eigenvectors of the reconstructed trans"+
|
|
78
|
+
"formation matrix are respectively:")
|
|
79
|
+
|
|
80
|
+
for eigenvector_index in range(eigenvectors.shape[1]):
|
|
81
|
+
|
|
82
|
+
eigenvector = eigenvectors[:,eigenvector_index]
|
|
83
|
+
|
|
84
|
+
eigenvalue = 0.0
|
|
85
|
+
|
|
86
|
+
for index, component in enumerate(eigenvector):
|
|
87
|
+
|
|
88
|
+
if np.abs(component)>1E-10:
|
|
89
|
+
|
|
90
|
+
eigenvalue = np.einsum('ij,j->i', transformation_matrix,
|
|
91
|
+
eigenvector)[index]/component
|
|
92
|
+
|
|
93
|
+
print(str(eigenvalue)+" <-> "+str(eigenvector))
|
|
94
|
+
|
|
95
|
+
# Initializes the lists of coordinates of the points on the boundary
|
|
96
|
+
# of the transformation
|
|
97
|
+
|
|
98
|
+
x_data = []
|
|
99
|
+
|
|
100
|
+
y_data = []
|
|
101
|
+
|
|
102
|
+
colors = []
|
|
103
|
+
|
|
104
|
+
# Iterates through the points
|
|
105
|
+
|
|
106
|
+
for j in range(n_points):
|
|
107
|
+
|
|
108
|
+
# Gets the angle of this point
|
|
109
|
+
|
|
110
|
+
angle = (j*(2*np.pi)/(n_points-1))+polar_angle_1
|
|
111
|
+
|
|
112
|
+
if angle<=polar_angle_2:
|
|
113
|
+
|
|
114
|
+
colors.append((angle-polar_angle_1)/(polar_angle_2-
|
|
115
|
+
polar_angle_1))
|
|
116
|
+
|
|
117
|
+
else:
|
|
118
|
+
|
|
119
|
+
colors.append(1.0-(angle-polar_angle_2)/((2*np.pi)-
|
|
120
|
+
polar_angle_2+polar_angle_1))
|
|
121
|
+
|
|
122
|
+
# Computes the polar coordinates and generates the input vector
|
|
123
|
+
|
|
124
|
+
input_vector = np.array([np.cos(angle), np.sin(angle)])
|
|
125
|
+
|
|
126
|
+
# Maps the input vector to the transformed coordinates
|
|
127
|
+
|
|
128
|
+
transformed_vector = np.einsum('ij,j->i', transformation_matrix,
|
|
129
|
+
input_vector)
|
|
130
|
+
|
|
131
|
+
# Appends the coordinates
|
|
132
|
+
|
|
133
|
+
x_data.append(transformed_vector[0])
|
|
134
|
+
|
|
135
|
+
y_data.append(transformed_vector[1])
|
|
136
|
+
|
|
137
|
+
plot_object = plane_plot("2D_linear_transformation", x_data=x_data,
|
|
138
|
+
y_data=y_data, plot_type="scatter", element_size=2.5, color=colors,
|
|
139
|
+
color_map="coolwarm", aspect_ratio=1.0)
|
|
140
|
+
|
|
141
|
+
# Plots the eigenvectors
|
|
142
|
+
|
|
143
|
+
colors = np.array([0.0, 1.0])
|
|
144
|
+
|
|
145
|
+
colors = colors[eigenvector_polar_indices].tolist()
|
|
146
|
+
|
|
147
|
+
plot_object = plane_plot("2D_linear_transformation", x_data=[[0.0,
|
|
148
|
+
column_eigenvectors_array[0,0]], [0.0, column_eigenvectors_array[0,1]]],
|
|
149
|
+
y_data=[[0.0, column_eigenvectors_array[1,0]], [0.0,
|
|
150
|
+
column_eigenvectors_array[1,1]]], plot_type="line", element_size=2.5,
|
|
151
|
+
color=colors, color_map="coolwarm", aspect_ratio=1.0, plot_object=
|
|
152
|
+
plot_object)
|
|
153
|
+
|
|
154
|
+
if __name__=="__main__":
|
|
155
|
+
|
|
156
|
+
column_eigenvectors_array_non_orthogonal = np.transpose(np.array([
|
|
157
|
+
[1.0, 1.0], [1.0, 0.0]]))
|
|
158
|
+
|
|
159
|
+
column_eigenvectors_array_orthogonal = np.transpose(np.array([
|
|
160
|
+
[1.0, 1.0], [-1.0, 1.0]]))
|
|
161
|
+
|
|
162
|
+
eigenvalues_array = np.array([1.0, 2.0])
|
|
163
|
+
|
|
164
|
+
generate_linear_2D_transformation(
|
|
165
|
+
column_eigenvectors_array_non_orthogonal, eigenvalues_array)
|
|
@@ -41,9 +41,9 @@ Davout/DeepMech/PINNs/Physics/elasticity_equation.py,sha256=4pNdELWMr1YzRgE1rNPn
|
|
|
41
41
|
Davout/DeepMech/aa_tests/heat_equation.py,sha256=3qmN2csugPF6gtHNGEJEEunv2WuxykzC4cS31D8vTCo,115
|
|
42
42
|
Davout/DeepMech/aa_tests/SVD_framework/box_with_imposed_displacement_gradient.py,sha256=uYtA_mcTyTRDV0YVZnniikZQ2-R82c22MtIM27qDf9E,8091
|
|
43
43
|
Davout/DeepMech/aa_tests/SVD_framework/box_with_young_modulus_field.py,sha256=GhBQljhwgoX-mw7TflLqXdEHqAUojGWLTXpOPhJl6gA,7942
|
|
44
|
-
Davout/DeepMech/aa_tests/SVD_framework/dataset_generator.py,sha256=
|
|
45
|
-
Davout/DeepMech/aa_tests/SVD_framework/input_data_filler.py,sha256=
|
|
46
|
-
Davout/DeepMech/aa_tests/SVD_framework/kinematics_surrogate_model.py,sha256=
|
|
44
|
+
Davout/DeepMech/aa_tests/SVD_framework/dataset_generator.py,sha256=XxCUCmQs197z6YKUhoXh3aAJM68vvEGv41VIlvTJVu4,14821
|
|
45
|
+
Davout/DeepMech/aa_tests/SVD_framework/input_data_filler.py,sha256=XHNifn6dB4DCpycGxsRvj4AE-innRuryyHAJzRj9Yas,6418
|
|
46
|
+
Davout/DeepMech/aa_tests/SVD_framework/kinematics_surrogate_model.py,sha256=Ly13PTBKB04jahfBYzRBIz8tYt0vR0_Nr7JKxsMFA0s,16391
|
|
47
47
|
Davout/DeepMech/aa_tests/SVD_framework/young_modulus_field_generator.py,sha256=MMiV_mUbPv4PnnvvAIeVK7ffI4sSRR0VyckTU-X4Q9U,4108
|
|
48
48
|
Davout/DeepMech/aa_tests/mecsol_2026_quotient_space/box_with_imposed_displacement_gradient.py,sha256=uYtA_mcTyTRDV0YVZnniikZQ2-R82c22MtIM27qDf9E,8091
|
|
49
49
|
Davout/DeepMech/aa_tests/mecsol_2026_quotient_space/box_with_young_modulus_field.py,sha256=GhBQljhwgoX-mw7TflLqXdEHqAUojGWLTXpOPhJl6gA,7942
|
|
@@ -71,6 +71,7 @@ Davout/DeepMech/tool_box/__init__.py,sha256=Z-4M72_OXM2ulw_X-_MxH4Sm018wFUGkvqgN
|
|
|
71
71
|
Davout/DeepMech/tool_box/activation_function_utilities.py,sha256=i4nTl7WYwPb9emGnRw6s5OfW89jUVeKPVRWRdpnzpgQ,6657
|
|
72
72
|
Davout/DeepMech/tool_box/custom_activation_functions.py,sha256=aJ5A7F9tsO_FY6QP1JnB01ZdGnlLWh-_mt60lUHoSPE,6551
|
|
73
73
|
Davout/DeepMech/tool_box/differentiation_tools.py,sha256=QinKzj3NBGxAUan1WDCR0Etn2_OeQZiFcYkjJrM7nxs,16042
|
|
74
|
+
Davout/DeepMech/tool_box/gpu_tools.py,sha256=5ECQU8SHAhJlhPtf0LEHK1fSprGYAC8UQ9r32p_svag,560
|
|
74
75
|
Davout/DeepMech/tool_box/loss_assembler_classes.py,sha256=XTWzxZuJzdngJdHKXzh8faufLsz8TtOVYZBes2Kh-2s,38393
|
|
75
76
|
Davout/DeepMech/tool_box/loss_tools.py,sha256=Nqbbk4V3GDivUgKMOVHkrY78F6NnsrJpWXgt045WX4w,3595
|
|
76
77
|
Davout/DeepMech/tool_box/math_tools.py,sha256=ZsgIaoCRP_V6GNEaK5loX4AqNop1u2E7griIsPMHdvQ,8461
|
|
@@ -131,6 +132,7 @@ Davout/GraphUtilities/aa_tests/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5
|
|
|
131
132
|
Davout/GraphUtilities/aa_tests/cauchy_tetrahedron.py,sha256=SiU-0iUNpviAbdj-f8HkRZUoJrWEXFT63t9eRH0tSW4,1669
|
|
132
133
|
Davout/GraphUtilities/aa_tests/continuum_mechanics_potato_collage.py,sha256=4mPNYhL8Pc6V7rwkZDDmGhSEsUkHz9keOEhAzjM6bjs,1710
|
|
133
134
|
Davout/GraphUtilities/aa_tests/fake_book_spines.py,sha256=3O3ZOmpni4Nz2f65n6RB9jxSXZlmcxpFGeAgMq4atiA,19656
|
|
135
|
+
Davout/GraphUtilities/aa_tests/linear_transformation_plot.py,sha256=qvU1x7qIkvmktpWBfYAIvK9IpJlS3KcVRmbcZ9tO_xU,5078
|
|
134
136
|
Davout/GraphUtilities/aa_tests/null_space_architecture.py,sha256=hfrp7ZZRpfzih2maXLrRVYXTbujiLHAjTqJfrq-2PXI,1708
|
|
135
137
|
Davout/GraphUtilities/aa_tests/positive_orthant_modulating_function.py,sha256=gpq735izEKX3xdOqqUcvQNAp9vhmtFWQfuKd-10hT7E,22889
|
|
136
138
|
Davout/GraphUtilities/aa_tests/strain_tensors.py,sha256=7dwpV5wOGmHgSZdUnUvgsi6sFV9QweUST_coIlGxlKw,3045
|
|
@@ -282,8 +284,8 @@ Davout/StochasticUtilities/tool_box/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQ
|
|
|
282
284
|
Davout/StochasticUtilities/tool_box/delaunay_tools.py,sha256=bWNk6tdcVg8RuSjaG4b0P33Tlb6X65rwuaHhaQ-B-Ac,23018
|
|
283
285
|
Davout/StochasticUtilities/tool_box/sampling_tools.py,sha256=3g2UyIDji1RHm5_yHlGPJx44DfiHgX6rAqo-cnX6yes,6539
|
|
284
286
|
Davout/StochasticUtilities/tool_box/statistics_tools.py,sha256=K1FMEz1hb-iKHqfSB-b5uYoweV_sp13iu-VYcu_CroY,828
|
|
285
|
-
davout-0.1.1.
|
|
286
|
-
davout-0.1.1.
|
|
287
|
-
davout-0.1.1.
|
|
288
|
-
davout-0.1.1.
|
|
289
|
-
davout-0.1.1.
|
|
287
|
+
davout-0.1.1.dev182.dist-info/licenses/LICENSE,sha256=OXLcl0T2SZ8Pmy2_dmlvKuetivmyPd5m1q-Gyd-zaYY,35149
|
|
288
|
+
davout-0.1.1.dev182.dist-info/METADATA,sha256=wLTMcPxFZFI-qUDgqrWWOm3OCKtwi9uljV1SyL0v3BE,4060
|
|
289
|
+
davout-0.1.1.dev182.dist-info/WHEEL,sha256=YCfwYGOYMi5Jhw2fU4yNgwErybb2IX5PEwBKV4ZbdBo,91
|
|
290
|
+
davout-0.1.1.dev182.dist-info/top_level.txt,sha256=MTnYOTokucuNOnet89jXWXY_s29ppLfi8K0GB3CEbNQ,7
|
|
291
|
+
davout-0.1.1.dev182.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|
|
File without changes
|