-
Notifications
You must be signed in to change notification settings - Fork 5
/
vevp_ml_model.cc
4605 lines (4017 loc) · 173 KB
/
vevp_ml_model.cc
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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
/* ---------------------------------------------------------------------
* Author: Betim Bahtiri, Leibniz Universit\"at Hannover, 2023"
*
*
* The deal.II library is free software; you can use it, redistribute
* it, and/or modify it under the terms of the GNU Lesser General
* Public License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
* The full text of the license can be found in the file LICENSE at
* the top level of the deal.II distribution.
*/
// We start by including all the necessary deal.II header files and some C++
// related ones. They have been discussed in detail in previous tutorial
// programs, so you need only refer to past tutorials for details.
#include <deal.II/base/function.h>
#include <deal.II/base/parameter_handler.h>
#include <deal.II/base/point.h>
#include <deal.II/base/quadrature_lib.h>
#include <deal.II/base/symmetric_tensor.h>
#include <deal.II/base/tensor.h>
#include <deal.II/base/timer.h>
#include <deal.II/base/work_stream.h>
#include <deal.II/base/quadrature_point_data.h>
#include <deal.II/dofs/dof_renumbering.h>
#include <deal.II/dofs/dof_tools.h>
#include <deal.II/grid/grid_generator.h>
#include <deal.II/grid/grid_tools.h>
#include <deal.II/grid/grid_in.h>
#include <deal.II/grid/tria.h>
#include <deal.II/grid/grid_out.h>
#include <deal.II/fe/fe_dgp_monomial.h>
#include <deal.II/fe/fe_q.h>
#include <deal.II/fe/fe_system.h>
#include <deal.II/fe/fe_tools.h>
#include <deal.II/fe/fe_values.h>
#include <deal.II/fe/mapping_q_eulerian.h>
#include <deal.II/fe/mapping_q.h>
#include <deal.II/lac/affine_constraints.h>
#include <deal.II/lac/block_sparse_matrix.h>
#include <deal.II/lac/block_vector.h>
#include <deal.II/lac/dynamic_sparsity_pattern.h>
#include <deal.II/lac/full_matrix.h>
#include <deal.II/lac/precondition_selector.h>
#include <deal.II/lac/solver_cg.h>
#include <deal.II/lac/sparse_direct.h>
#include <deal.II/numerics/data_out.h>
#include <deal.II/numerics/vector_tools.h>
#include <deal.II/numerics/fe_field_function.h>
#include <deal.II/base/config.h>
#if DEAL_II_VERSION_MAJOR >= 9 && defined(DEAL_II_WITH_TRILINOS)
#include <deal.II/differentiation/ad.h>
#define ENABLE_SACADO_FORMULATION
#endif
#include <deal.II/physics/elasticity/kinematics.h>
#include <deal.II/physics/elasticity/standard_tensors.h>
#include <deal.II/physics/transformations.h>
#include <iostream>
#include <fstream>
#include <memory>
#include <cmath>
#include <vector>
#include <cstdio>
#include </bigwork/nhgebaht/FEM/Eigen3/Eigen/Dense>
namespace vevpd_model
{
using namespace dealii;
using Eigen::MatrixXd;
using Eigen::VectorXd;
using Eigen::ArrayXXd;
using Eigen::ArrayXd;
// There are several parameters that can be set in the code so we set up a
// ParameterHandler object to read in the choices at run-time.
namespace Parameters
{
// @sect4{Assembly method}
// Here we specify whether automatic differentiation is to be used to assemble
// the linear system, and if so then what order of differentiation is to be
// employed.
struct AssemblyMethod
{
unsigned int automatic_differentiation_order;
static void
declare_parameters(ParameterHandler &prm);
void
parse_parameters(ParameterHandler &prm);
};
void AssemblyMethod::declare_parameters(ParameterHandler &prm)
{
prm.enter_subsection("Assembly method");
{
prm.declare_entry("Automatic differentiation order", "0",
Patterns::Integer(0,2),
"The automatic differentiation order to be used in the assembly of the linear system.\n"
"# Order = 0: Both the residual and linearisation are computed manually.\n"
"# Order = 1: The residual is computed manually but the linearisation is performed using AD.\n"
"# Order = 2: Both the residual and linearisation are computed using AD.");
}
prm.leave_subsection();
}
void AssemblyMethod::parse_parameters(ParameterHandler &prm)
{
prm.enter_subsection("Assembly method");
{
automatic_differentiation_order = prm.get_integer("Automatic differentiation order");
}
prm.leave_subsection();
}
struct BoundaryConditions
{
double stretch1;
double stretch2;
double stretch3;
double stretch4;
double stretch5;
double stretch6;
double stretch7;
double unload_time_first;
double unload_time_second;
double unload_time_third;
double unload_time_fourth;
double unload_time_fifth;
double unload_time_sixth;
std::string load_type;
int total_cycles;
static void
declare_parameters(ParameterHandler &prm);
void
parse_parameters(ParameterHandler &prm);
};
void BoundaryConditions::declare_parameters(ParameterHandler &prm)
{
prm.enter_subsection("Boundary conditions");
{
prm.declare_entry("First stretch", "1.04",
Patterns::Double(0.0),
"Positive stretch applied length-ways to the model");
prm.declare_entry("Second stretch", "1.04",
Patterns::Double(0.0),
"Positive stretch applied length-ways to the model");
prm.declare_entry("Third stretch", "1.04",
Patterns::Double(0.0),
"Positive stretch applied length-ways to the model");
prm.declare_entry("Fourth stretch", "1.04",
Patterns::Double(0.0),
"Positive stretch applied length-ways to the model");
prm.declare_entry("Fifth stretch", "1.04",
Patterns::Double(0.0),
"Positive stretch applied length-ways to the model");
prm.declare_entry("Sixth stretch", "1.04",
Patterns::Double(0.0),
"Positive stretch applied length-ways to the model");
prm.declare_entry("Seventh stretch", "1.04",
Patterns::Double(0.0),
"Positive stretch applied length-ways to the model");
prm.declare_entry("Load type", "cyclic_to_zero",
Patterns::Selection("none|cyclic_to_zero"),
"Type of loading");
prm.declare_entry("Total cycles", "1.04",
Patterns::Double(0.0),
"Total number of cycles");
}
prm.leave_subsection();
}
void BoundaryConditions::parse_parameters(ParameterHandler &prm)
{
prm.enter_subsection("Boundary conditions");
{
stretch1 = prm.get_double("First stretch");
stretch2 = prm.get_double("Second stretch");
stretch3 = prm.get_double("Third stretch");
stretch4 = prm.get_double("Fourth stretch");
stretch5 = prm.get_double("Fifth stretch");
stretch6 = prm.get_double("Sixth stretch");
stretch7 = prm.get_double("Seventh stretch");
load_type = prm.get("Load type");
total_cycles = prm.get_integer("Total cycles");
}
prm.leave_subsection();
}
// Here we specify the polynomial order used to approximate the solution.
// The quadrature order should be adjusted accordingly.
struct FESystem
{
unsigned int poly_degree;
unsigned int quad_order;
std::string switchML;
int hidden_size;
double alpha;
static void
declare_parameters(ParameterHandler &prm);
void
parse_parameters(ParameterHandler &prm);
};
void FESystem::declare_parameters(ParameterHandler &prm)
{
prm.enter_subsection("Finite element system");
{
prm.declare_entry("Polynomial degree", "2",
Patterns::Integer(0),
"Displacement system polynomial order");
prm.declare_entry("Quadrature order", "3",
Patterns::Integer(0),
"Gauss quadrature order");
prm.declare_entry("Switch to ML", "On",
Patterns::Selection("On|Off"),
"Switch to ML");
prm.declare_entry("LSTM", "2",
Patterns::Integer(0),
"LSTM");
prm.declare_entry("alpha", "1e-4",
Patterns::Double(0.0),
"alpha");
}
prm.leave_subsection();
}
void FESystem::parse_parameters(ParameterHandler &prm)
{
prm.enter_subsection("Finite element system");
{
poly_degree = prm.get_integer("Polynomial degree");
quad_order = prm.get_integer("Quadrature order");
switchML = prm.get("Switch to ML");
hidden_size = prm.get_integer("LSTM");
alpha = prm.get_double("alpha");
}
prm.leave_subsection();
}
// @sect4{Materials}
// We also need the shear modulus $ \mu $ and Poisson ration $ \nu $ for the
// neo-Hookean material.
struct Materials
{
double mu1;
double mu2;
double m;
double gamma_dot_0;
double dG;
double Ad;
double tau0;
double d0s;
double m_tau;
double a;
double b;
double sigma0;
double nu1;
double nu2;
double de;
double temp;
double zita;
double wnp;
double y0;
double x0;
double a_t;
double b_t;
static void
declare_parameters(ParameterHandler &prm);
void
parse_parameters(ParameterHandler &prm);
};
void Materials::declare_parameters(ParameterHandler &prm)
{
prm.enter_subsection("Material properties");
{
prm.declare_entry("mu1", "800.0",
Patterns::Double(),
"mu1");
prm.declare_entry("mu2", "401.2",
Patterns::Double(),
"mu2");
prm.declare_entry("m", "0.692",
Patterns::Double(),
"m");
prm.declare_entry("gamma_dot_0", "3.403e-2",
Patterns::Double(),
"gamma_dot_0");
prm.declare_entry("dG", "3.783e-25",
Patterns::Double(),
"dG");
prm.declare_entry("Ad", "455.30",
Patterns::Double(),
"Ad");
prm.declare_entry("tau0", "27.11",
Patterns::Double(),
"tau0");
prm.declare_entry("d0s", "0.851",
Patterns::Double(),
"d0s");
prm.declare_entry("m_tau", "7.96",
Patterns::Double(),
"m_tau");
prm.declare_entry("a", "0.996",
Patterns::Double(),
"a");
prm.declare_entry("b", "0.234",
Patterns::Double(),
"b");
prm.declare_entry("sigma0", "20.2",
Patterns::Double(),
"sigma0");
prm.declare_entry("nu1", "0.4318",
Patterns::Double(-1.0,0.5),
"nu1");
prm.declare_entry("nu2", "0.4318",
Patterns::Double(-1.0,0.5),
"nu2");
prm.declare_entry("de", "1e-4",
Patterns::Double(),
"de");
prm.declare_entry("temp", "296.0",
Patterns::Double(),
"temp");
prm.declare_entry("zita", "0.0",
Patterns::Double(),
"zita");
prm.declare_entry("wnp", "0.0",
Patterns::Double(),
"wnp");
prm.declare_entry("y0", "0.0",
Patterns::Double(),
"wnp");
prm.declare_entry("x0", "0.0",
Patterns::Double(),
"wnp");
prm.declare_entry("a_t", "0.0",
Patterns::Double(),
"wnp");
prm.declare_entry("b_t", "0.0",
Patterns::Double(),
"wnp");
}
prm.leave_subsection();
}
void Materials::parse_parameters(ParameterHandler &prm)
{
prm.enter_subsection("Material properties");
{
mu1 = prm.get_double("mu1");
mu2 = prm.get_double("mu2");
m = prm.get_double("m");
gamma_dot_0 = prm.get_double("gamma_dot_0");
dG = prm.get_double("dG");
Ad = prm.get_double("Ad");
tau0 = prm.get_double("tau0");
d0s = prm.get_double("d0s");
m_tau = prm.get_double("m_tau");
a = prm.get_double("a");
b = prm.get_double("b");
sigma0 = prm.get_double("sigma0");
nu1 = prm.get_double("nu1");
nu2 = prm.get_double("nu2");
de = prm.get_double("de");
temp = prm.get_double("temp");
zita = prm.get_double("zita");
wnp = prm.get_double("wnp");
y0 = prm.get_double("y0");
x0 = prm.get_double("x0");
a_t = prm.get_double("a_t");
b_t = prm.get_double("b_t");
}
prm.leave_subsection();
}
// @sect4{Linear solver}
// Next, we choose both solver and preconditioner settings. The use of an
// effective preconditioner is critical to ensure convergence when a large
// nonlinear motion occurs within a Newton increment.
struct LinearSolver
{
std::string type_lin;
double tol_lin;
double max_iterations_lin;
std::string preconditioner_type;
double preconditioner_relaxation;
static void
declare_parameters(ParameterHandler &prm);
void
parse_parameters(ParameterHandler &prm);
};
void LinearSolver::declare_parameters(ParameterHandler &prm)
{
prm.enter_subsection("Linear solver");
{
prm.declare_entry("Solver type", "CG",
Patterns::Selection("CG|Direct"),
"Type of solver used to solve the linear system");
prm.declare_entry("Residual", "1e-6",
Patterns::Double(0.0),
"Linear solver residual (scaled by residual norm)");
prm.declare_entry("Max iteration multiplier", "1",
Patterns::Double(0.0),
"Linear solver iterations (multiples of the system matrix size)");
prm.declare_entry("Preconditioner type", "ssor",
Patterns::Selection("jacobi|ssor"),
"Type of preconditioner");
prm.declare_entry("Preconditioner relaxation", "0.65",
Patterns::Double(0.0),
"Preconditioner relaxation value");
}
prm.leave_subsection();
}
void LinearSolver::parse_parameters(ParameterHandler &prm)
{
prm.enter_subsection("Linear solver");
{
type_lin = prm.get("Solver type");
tol_lin = prm.get_double("Residual");
max_iterations_lin = prm.get_double("Max iteration multiplier");
preconditioner_type = prm.get("Preconditioner type");
preconditioner_relaxation = prm.get_double("Preconditioner relaxation");
}
prm.leave_subsection();
}
// @sect4{Nonlinear solver}
// A Newton-Raphson scheme is used to solve the nonlinear system of governing
// equations. We now define the tolerances and the maximum number of
// iterations for the Newton-Raphson nonlinear solver.
struct NonlinearSolver
{
unsigned int max_iterations_NR;
double tol_f;
double tol_u;
static void
declare_parameters(ParameterHandler &prm);
void
parse_parameters(ParameterHandler &prm);
};
void NonlinearSolver::declare_parameters(ParameterHandler &prm)
{
prm.enter_subsection("Nonlinear solver");
{
prm.declare_entry("Max iterations Newton-Raphson", "10",
Patterns::Integer(0),
"Number of Newton-Raphson iterations allowed");
prm.declare_entry("Tolerance force", "1.0e-9",
Patterns::Double(0.0),
"Force residual tolerance");
prm.declare_entry("Tolerance displacement", "1.0e-6",
Patterns::Double(0.0),
"Displacement error tolerance");
}
prm.leave_subsection();
}
void NonlinearSolver::parse_parameters(ParameterHandler &prm)
{
prm.enter_subsection("Nonlinear solver");
{
max_iterations_NR = prm.get_integer("Max iterations Newton-Raphson");
tol_f = prm.get_double("Tolerance force");
tol_u = prm.get_double("Tolerance displacement");
}
prm.leave_subsection();
}
// @sect4{Time}
// Set the timestep size $ \varDelta t $ and the simulation end-time.
struct Time
{
double delta_t_1;
double delta_t_2;
double end_time;
int intToML;
double delta_de;
double load_rate;
int intRedDe;
double RedAmount;
static void
declare_parameters(ParameterHandler &prm);
void
parse_parameters(ParameterHandler &prm);
};
void Time::declare_parameters(ParameterHandler &prm)
{
prm.enter_subsection("Time");
{
prm.declare_entry("End time", "1",
Patterns::Double(),
"End time");
prm.declare_entry("Time step size", "0.1",
Patterns::Double(),
"Time step size");
prm.declare_entry("Time step size 2", "0.01",
Patterns::Double(),
"Time step size 2");
prm.declare_entry("At which timestep switch to ML ?", "0",
Patterns::Integer(),
"At which timestep switch to ML ?");
prm.declare_entry("Delta de", "1e-5",
Patterns::Double(0.0),
"Delta de");
prm.declare_entry("load_rate", "1e-4",
Patterns::Double(0.0),
"load_rate");
prm.declare_entry("reduce_at_timestep", "500",
Patterns::Integer(0),
"reduce_at_timestep");
prm.declare_entry("reduce_timestep", "0.5",
Patterns::Double(0.0),
"reduce_timestep");
}
prm.leave_subsection();
}
void Time::parse_parameters(ParameterHandler &prm)
{
prm.enter_subsection("Time");
{
end_time = prm.get_double("End time");
delta_t_1 = prm.get_double("Time step size");
delta_t_2 = prm.get_double("Time step size 2");
intToML = prm.get_integer("At which timestep switch to ML ?");
delta_de = prm.get_double("Delta de");
load_rate = prm.get_double("load_rate");
intRedDe = prm.get_integer("reduce_at_timestep");
RedAmount = prm.get_double("reduce_timestep");
}
prm.leave_subsection();
}
struct OutputParam
{
unsigned int timestep_output;
std::string outtype;
static void
declare_parameters(ParameterHandler &prm);
void
parse_parameters(ParameterHandler &prm);
};
void OutputParam::declare_parameters(ParameterHandler &prm)
{
prm.enter_subsection("Output parameters");
{
prm.declare_entry("Time step number output", "1",
Patterns::Integer(0),
"Output data for time steps multiple of the given "
"integer value.");
prm.declare_entry("Averaged results", "nodes",
Patterns::Selection("elements|nodes"),
"Output data associated with integration point values"
" averaged on elements or on nodes.");
}
prm.leave_subsection();
}
void OutputParam::parse_parameters(ParameterHandler &prm)
{
prm.enter_subsection("Output parameters");
{
timestep_output = prm.get_integer("Time step number output");
outtype = prm.get("Averaged results");
}
prm.leave_subsection();
}
// @sect4{All parameters}
// Finally we consolidate all of the above structures into a single container
// that holds all of our run-time selections.
struct AllParameters :
public AssemblyMethod,
public BoundaryConditions,
public FESystem,
public Materials,
public LinearSolver,
public NonlinearSolver,
public Time,
public OutputParam
{
AllParameters(const std::string &input_file);
static void
declare_parameters(ParameterHandler &prm);
void
parse_parameters(ParameterHandler &prm);
};
AllParameters::AllParameters(const std::string &input_file)
{
ParameterHandler prm;
declare_parameters(prm);
prm.parse_input(input_file);
parse_parameters(prm);
}
void AllParameters::declare_parameters(ParameterHandler &prm)
{
AssemblyMethod::declare_parameters(prm);
BoundaryConditions::declare_parameters(prm);
FESystem::declare_parameters(prm);
Materials::declare_parameters(prm);
LinearSolver::declare_parameters(prm);
NonlinearSolver::declare_parameters(prm);
Time::declare_parameters(prm);
OutputParam::declare_parameters(prm);
}
void AllParameters::parse_parameters(ParameterHandler &prm)
{
AssemblyMethod::parse_parameters(prm);
BoundaryConditions::parse_parameters(prm);
FESystem::parse_parameters(prm);
Materials::parse_parameters(prm);
LinearSolver::parse_parameters(prm);
NonlinearSolver::parse_parameters(prm);
Time::parse_parameters(prm);
OutputParam::parse_parameters(prm);
}
}
// @sect3{Time class}
// A simple class to store time data. Its functioning is transparent so no
// discussion is necessary. For simplicity we assume a constant time step
// size.
class Time
{
public:
Time (const double time_end,
const double delta_t_1, const double delta_t_2, const double delta_de,
const double load_rate)
:
timestep(0.0),
time_current(0.0),
time_end(time_end),
delta_t_1(delta_t_1),
delta_t_2(delta_t_2),
delta_de(delta_de),
load_rate(load_rate),
delta_t(delta_de/load_rate)
{}
virtual ~Time()
{}
double current() const
{
return time_current;
}
double end() const
{
return time_end;
}
double get_delta_t() const
{
return delta_t;
}
int get_timestep() const
{
return timestep;
}
void increment()
{
time_current += delta_t;
++timestep;
}
void adjust_timestep_size(const int &flag)
{
if (flag == 0)
delta_t = delta_t_2;
else if (flag == 1)
delta_t = delta_t_1;
}
int timestep;
double time_current;
const double time_end;
double delta_t_1;
double delta_t_2;
double delta_de;
double load_rate;
double delta_t;
};
// Here the viscoelastic, viscoplastic, damage model is implemented
template <int dim,typename NumberType>
class Material_Compressible_Network
{
public:
Material_Compressible_Network(const Parameters::AllParameters ¶meters,
const Time &time)
:
mu1(parameters.mu1),
mu2(parameters.mu2),
nu1(parameters.nu1),
nu2(parameters.nu2),
lambda_nh1((2*mu1*nu1)/(1-2*nu1)),
lambda_nh2((2*mu2*nu2)/(1-2*nu2)),
m(parameters.m),
gamma_dot_0(parameters.gamma_dot_0),
dG(parameters.dG),
Ad(parameters.Ad),
tau0(parameters.tau0),
d0s(parameters.d0s),
m_tau(parameters.m_tau),
a(parameters.a),
b(parameters.b),
sigma0(parameters.sigma0),
de(parameters.de),
y0(parameters.y0),
x0(parameters.x0),
a_t(parameters.a_t),
b_t(parameters.b_t),
d(0.0),
d_converged(0.0),
eps0(0.0),
eps0_converged(0.0),
F_b_t(Physics::Elasticity::StandardTensors<dim>::I),
F_p_t(Physics::Elasticity::StandardTensors<dim>::I),
F_b_t_converged(Physics::Elasticity::StandardTensors<dim>::I),
F_p_t_converged(Physics::Elasticity::StandardTensors<dim>::I),
lc_max(1.0),
lc_max_converged(1.0),
strain(0.0),
strain_converged(0.0),
time(time),
kappa((2.0 * mu1 * (1.0 + nu1)) / (3.0 * (1.0 - 2.0 * nu1))),
c_1(mu1 / 2.0),
Temper(parameters.temp),
zita(parameters.zita),
Tref(296.0),
alphaZ(1+0.057*pow(zita,2)-9.5*zita),
alphaT(2-exp(0.0126*(Temper-Tref))),
wnp(parameters.wnp),
ro_p(1.2),
ro_np(3.0),
vnp(wnp * ro_p / (ro_np + wnp*ro_p - ro_np*wnp)),
X((1+5.0*vnp+18*pow(vnp,2))*alphaZ*alphaT),
changetoML(parameters.intToML),
intHiSi(parameters.hidden_size),
alpha(parameters.alpha)
{
Assert(lambda_nh1 > 0, ExcInternalError());
}
virtual ~Material_Compressible_Network()
{}
void
read_inML()
{
for (int k = 0; k < files; k++)
{
double myArray[file_rows[k]][file_columns[k]];
if (k == 0)
{
std::ifstream inputfile("muX.txt");
for (int r = 0; r < file_rows[k]; r++) //Outer loop for rows
{
for (int c = 0; c < file_columns[k]; c++) //inner loop for columns
{
inputfile >> myArray[r][c]; //Take input from file and put into myArray
this->muX(r,c) = 0.0;
this->muX(r,c) = myArray[r][c];
}
}
}
else if(k == 1)
{
std::ifstream inputfile("muT.txt");
for (int r = 0; r < file_rows[k]; r++) //Outer loop for rows
{
for (int c = 0; c < file_columns[k]; c++) //inner loop for columns
{
inputfile >> myArray[r][c]; //Take input from file and put into myArray
this->muT(r,c) = 0.0;
this->muT(r,c) = myArray[r][c];
}
}
}
else if(k == 2)
{
std::ifstream inputfile("sigmaX.txt");
for (int r = 0; r < file_rows[k]; r++) //Outer loop for rows
{
for (int c = 0; c < file_columns[k]; c++) //inner loop for columns
{
inputfile >> myArray[r][c]; //Take input from file and put into myArray
this->sigmaX(r,c) = 0.0;
this->sigmaX(r,c) = myArray[r][c];
}
}
}
else if(k == 3)
{
std::ifstream inputfile("sigmaT.txt");
for (int r = 0; r < file_rows[k]; r++) //Outer loop for rows
{
for (int c = 0; c < file_columns[k]; c++) //inner loop for columns
{
inputfile >> myArray[r][c]; //Take input from file and put into myArray
this->sigmaT(r,c) = 0.0;
this->sigmaT(r,c) = myArray[r][c];
}
}
}
else if(k == 4)
{
std::ifstream inputfile("iweights_lstm1.txt");
for (int r = 0; r < file_rows[k]; r++) //Outer loop for rows
{
for (int c = 0; c < file_columns[k]; c++) //inner loop for columns
{
inputfile >> myArray[r][c]; //Take input from file and put into myArray
this->iweights_lstm1(r,c) = 0.0;
this->iweights_lstm1(r,c) = myArray[r][c];
}
}
}
else if(k == 5)
{
std::ifstream inputfile("iweights_lstm2.txt");
for (int r = 0; r < file_rows[k]; r++) //Outer loop for rows
{
for (int c = 0; c < file_columns[k]; c++) //inner loop for columns
{
inputfile >> myArray[r][c]; //Take input from file and put into myArray
this->iweights_lstm2(r,c) = 0.0;
this->iweights_lstm2(r,c) = myArray[r][c];
}
}
}
else if(k == 6)
{
std::ifstream inputfile("rweights_lstm1.txt");
for (int r = 0; r < file_rows[k]; r++) //Outer loop for rows
{
for (int c = 0; c < file_columns[k]; c++) //inner loop for columns
{
inputfile >> myArray[r][c]; //Take input from file and put into myArray
this->rweights_lstm1(r,c) = 0.0;
this->rweights_lstm1(r,c) = myArray[r][c];
}
}
}
else if(k == 7)
{
std::ifstream inputfile("rweights_lstm2.txt");
for (int r = 0; r < file_rows[k]; r++) //Outer loop for rows
{
for (int c = 0; c < file_columns[k]; c++) //inner loop for columns
{
inputfile >> myArray[r][c]; //Take input from file and put into myArray
this->rweights_lstm2(r,c) = 0.0;
this->rweights_lstm2(r,c) = myArray[r][c];
}
}
}
else if(k == 8)
{
std::ifstream inputfile("bias_lstm1.txt");
for (int r = 0; r < file_rows[k]; r++) //Outer loop for rows
{
for (int c = 0; c < file_columns[k]; c++) //inner loop for columns
{
inputfile >> myArray[r][c]; //Take input from file and put into myArray
this->bias_lstm1(r,c) = 0.0;
this->bias_lstm1(r,c) = myArray[r][c];
}
}
}
else if(k == 9)
{
std::ifstream inputfile("bias_lstm2.txt");
for (int r = 0; r < file_rows[k]; r++) //Outer loop for rows
{
for (int c = 0; c < file_columns[k]; c++) //inner loop for columns
{
inputfile >> myArray[r][c]; //Take input from file and put into myArray
this->bias_lstm2(r,c) = 0.0;
this->bias_lstm2(r,c) = myArray[r][c];
}
}
}
else if(k == 10)
{
std::ifstream inputfile("weights_cl.txt");
for (int r = 0; r < file_rows[k]; r++) //Outer loop for rows
{
for (int c = 0; c < file_columns[k]; c++) //inner loop for columns
{
inputfile >> myArray[r][c]; //Take input from file and put into myArray
this->weights_cl(r,c) = 0.0;
this->weights_cl(r,c) = myArray[r][c];
}
}
}
else if(k == 11)
{
std::ifstream inputfile("bias_cl.txt");
for (int r = 0; r < file_rows[k]; r++) //Outer loop for rows
{
for (int c = 0; c < file_columns[k]; c++) //inner loop for columns