idaholab / mastodon

A MOOSE app for structural dynamics, seismic analysis, and risk assessment.
https://mooseframework.inl.gov/mastodon
GNU Lesser General Public License v2.1
40 stars 52 forks source link

Extend example 3 to AD #238

Closed cbolisetti closed 4 years ago

cbolisetti commented 4 years ago

We need to extend the nonlinear site-response problem in example 3 to use AD.

somu15 commented 4 years ago

I'm trying to run the analysis with AD. It is running, but slightly slowly. Do I have to make any changes to my input file? (see below)

somu15 commented 4 years ago

[Mesh] type = GeneratedMesh nx = 1 ny = 1 nz = 20 xmin = -0.5 ymin = -0.5 zmin = 0.0 xmax = 0.5 ymax = 0.5 zmax = 20.0 dim = 3 []

[GlobalParams] displacements = 'disp_x disp_y disp_z' []

[Variables] [./disp_x] [../] [./disp_y] [../] [./disp_z] [../] []

[AuxVariables] [./vel_x] [../] [./accel_x] [../] [./vel_y] [../] [./accel_y] [../] [./vel_z] [../] [./accel_z] [../] [./layer_id] order = CONSTANT family = MONOMIAL [../] []

[Kernels] [./DynamicTensorMechanics] displacements = 'disp_x disp_y disp_z' zeta = 0.000781 use_automatic_differentiation = true use_displaced_mesh = false [../] [./inertia_x] type = InertialForce variable = disp_x velocity = vel_x acceleration = accel_x beta = 0.25 gamma = 0.5 eta = 0.64026 use_displaced_mesh = false [../] [./inertia_y] type = InertialForce variable = disp_y velocity = vel_y acceleration = accel_y beta = 0.25 gamma = 0.5 eta = 0.64026 use_displaced_mesh = false [../] [./inertia_z] type = InertialForce variable = disp_z velocity = vel_z acceleration = accel_z beta = 0.25 gamma = 0.5 eta = 0.64026 use_displaced_mesh = false [../] [./gravity] type = Gravity variable = disp_z value = -9.81 use_displaced_mesh = false [../] []

[AuxKernels] [./accel_x] type = NewmarkAccelAux variable = accel_x displacement = disp_x velocity = vel_x beta = 0.25 execute_on = timestep_end [../] [./vel_x] type = NewmarkVelAux variable = vel_x acceleration = accel_x gamma = 0.5 execute_on = timestep_end [../] [./accel_y] type = NewmarkAccelAux variable = accel_y displacement = disp_y velocity = vel_y beta = 0.25 execute_on = timestep_end [../] [./vel_y] type = NewmarkVelAux variable = vel_y acceleration = accel_y gamma = 0.5 execute_on = timestep_end [../] [./accel_z] type = NewmarkAccelAux variable = accel_z displacement = disp_z velocity = vel_z beta = 0.25 execute_on = timestep_end [../] [./vel_z] type = NewmarkVelAux variable = vel_z acceleration = accel_z gamma = 0.5 execute_on = timestep_end [../] [./layer_id] type = UniformLayerAuxKernel variable = layer_id interfaces = '1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20.2' direction = '0.0 0.0 1.0' execute_on = initial [../] []

[BCs] [./bottom_z] type = PresetBC variable = disp_z boundary = 'back' value = 0.0 [../] [./bottom_y] type = PresetBC variable = disp_y boundary = 'back' value = 0.0 [../] [./bottom_accel] type = PresetAcceleration boundary = 'back' function = accel_bottom variable = 'disp_x' beta = 0.25 acceleration = 'accel_x' velocity = 'vel_x' [../] [./Periodic] [./y_dir] variable = 'disp_x disp_y disp_z' primary = 'bottom' secondary = 'top' translation = '0.0 1.0 0.0' [../] [./x_dir] variable = 'disp_x disp_y disp_z' primary = 'left' secondary = 'right' translation = '1.0 0.0 0.0' [../] [../] []

[Functions] [./accel_bottom] type = PiecewiseLinear data_file = chichi_bc_mpss_xp20.csv format = 'columns' [../] [./initial_zz] type = ParsedFunction value = '-2000.0 9.81 (20.0 - z)' [../] [./initial_xx] type = ParsedFunction value = '-2000.0 9.81 (20.0 - z) * 0.3/0.7' [../] []

[Materials] [./soil_all] block = 0 layer_variable = layer_id layer_ids = '0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19' initial_soil_stress = 'initial_xx 0 0 0 initial_xx 0 0 0 initial_zz' poissons_ratio = '0.3 0.3 0.3 0.3 0.3 0.3 0.3 0.3 0.3 0.3 0.3 0.3 0.3 0.3 0.3 0.3 0.3 0.3 0.3 0.3' type = ADComputeISoilStress soil_type = 'gqh' number_of_points = 100

GQ/H

   initial_shear_modulus = '125000000 118098000 111392000 103968000 96800000 89888000 83232000 76832000 70688000 64800000 59168000 53792000 48672000 43808000 39200000 34848000 30752000 26912000 23328000 20000000'
   theta_1 = '-6.66 -6.86 -7.06 -7.35 -7.65 -7.95 -8.3 -8.61 -8.95 -9.3 -9.61 -9.92 -10.0 -10.0 -10.0 -10.0 -10.0 -9.31 -7.17 -5.54'
   theta_2 = '5.5 5.7 5.9 6.2 6.6 6.9 7.3 7.6 8.0 8.4 8.6 8.8 8.82 8.71 8.55 8.3 7.88 6.4 2.4 -2.28'
   theta_3 = '1.0 1.0 1.0 1.0 1.0 1.0 1.0 1.0 1.0 1.0 1.0 1.0 1.0 1.0 1.0 1.0 1.0 1.0 1.0 1.0'
   theta_4 = '1.0 1.0 1.0 1.0 1.0 1.0 1.0 1.0 1.0 1.0 1.0 1.0 1.0 1.0 1.0 1.0 1.0 1.0 1.0 1.0'
   theta_5 = '0.99 0.99 0.99 0.99 0.99 0.99 0.99 0.99 0.99 0.99 0.99 0.99 0.99 0.99 0.99 0.99 0.99 0.99 0.99 0.99'
   taumax = '292500 277500 262500 247500 232500 217500 202500 187500 172500 157500 142500 127500 112500 97500 82500 67500 52500 37500 22500 7500'
   p_ref = '236841 224695 212550 200404 188258 176112 163967 151821 139675 127530 115384 103238 91092 78947 66801 54655 42510 30364 18218 6072'
   ######
   a0 = 1.0
   a1 = 0.0
   a2 = 0.0
   b_exp = 0.0

[../] [./sample_isoil_strain] type = ADComputeIncrementalSmallStrain block = 0 displacements = 'disp_x disp_y disp_z' [../] [./sample_isoil_elasticitytensor] type = ComputeIsotropicElasticityTensorSoil block = 0 elastic_modulus = '325000000 307054800 289619200 270316800 251680000 233708800 216403200 199763200 183788800 168480000 153836800 139859200 126547200 113900800 101920000 90604800 79955200 69971200 60652800 52000000' poissons_ratio = '0.3 0.3 0.3 0.3 0.3 0.3 0.3 0.3 0.3 0.3 0.3 0.3 0.3 0.3 0.3 0.3 0.3 0.3 0.3 0.3' density = '2000.0 2000.0 2000.0 2000.0 2000.0 2000.0 2000.0 2000.0 2000.0 2000.0 2000.0 2000.0 2000.0 2000.0 2000.0 2000.0 2000.0 2000.0 2000.0 2000.0' wave_speed_calculation = false layer_ids = '0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19' layer_variable = layer_id [../] []

[Preconditioning] [./andy] type = SMP full = true [../] []

[Executioner] type = Transient solve_type = NEWTON nl_abs_tol = 1e-6 nl_rel_tol = 1e-6 start_time = 0 end_time = 85.4 dt = 0.01 timestep_tolerance = 1e-6 petsc_options = '-snes_check_jacobian' []

[Postprocessors] [./accelx_top] type = PointValue point = '0.0 0.0 20.0' variable = accel_x [../] [./accelx_top1] type = PointValue point = '0.0 0.0 19.0' variable = accel_x [../] [./accelx_mid] type = PointValue point = '0.0 0.0 10.0' variable = accel_x [../] [./accelx_bot] type = PointValue point = '0.0 0.0 0.0' variable = accel_x [../] []

[Outputs] csv = true exodus = true perf_graph = true print_linear_residuals = false [./screen] type = Console max_rows = 1 interval = 1000 [../] []

cbolisetti commented 4 years ago

What do you mean by slow? Is it slower than not using AD?

On Thu, Aug 29, 2019 at 4:19 PM Som Dhulipala notifications@github.com wrote:

[Mesh] type = GeneratedMesh nx = 1 ny = 1 nz = 20 xmin = -0.5 ymin = -0.5 zmin = 0.0 xmax = 0.5 ymax = 0.5 zmax = 20.0 dim = 3 []

[GlobalParams] displacements = 'disp_x disp_y disp_z' []

[Variables] [./disp_x] [../] [./disp_y] [../] [./disp_z] [../] []

[AuxVariables] [./vel_x] [../] [./accel_x] [../] [./vel_y] [../] [./accel_y] [../] [./vel_z] [../] [./accel_z] [../] [./layer_id] order = CONSTANT family = MONOMIAL [../] []

[Kernels] [./DynamicTensorMechanics] displacements = 'disp_x disp_y disp_z' zeta = 0.000781 use_automatic_differentiation = true use_displaced_mesh = false [../] [./inertia_x] type = InertialForce variable = disp_x velocity = vel_x acceleration = accel_x beta = 0.25 gamma = 0.5 eta = 0.64026 use_displaced_mesh = false [../] [./inertia_y] type = InertialForce variable = disp_y velocity = vel_y acceleration = accel_y beta = 0.25 gamma = 0.5 eta = 0.64026 use_displaced_mesh = false [../] [./inertia_z] type = InertialForce variable = disp_z velocity = vel_z acceleration = accel_z beta = 0.25 gamma = 0.5 eta = 0.64026 use_displaced_mesh = false [../] [./gravity] type = Gravity variable = disp_z value = -9.81 use_displaced_mesh = false [../] []

[AuxKernels] [./accel_x] type = NewmarkAccelAux variable = accel_x displacement = disp_x velocity = vel_x beta = 0.25 execute_on = timestep_end [../] [./vel_x] type = NewmarkVelAux variable = vel_x acceleration = accel_x gamma = 0.5 execute_on = timestep_end [../] [./accel_y] type = NewmarkAccelAux variable = accel_y displacement = disp_y velocity = vel_y beta = 0.25 execute_on = timestep_end [../] [./vel_y] type = NewmarkVelAux variable = vel_y acceleration = accel_y gamma = 0.5 execute_on = timestep_end [../] [./accel_z] type = NewmarkAccelAux variable = accel_z displacement = disp_z velocity = vel_z beta = 0.25 execute_on = timestep_end [../] [./vel_z] type = NewmarkVelAux variable = vel_z acceleration = accel_z gamma = 0.5 execute_on = timestep_end [../] [./layer_id] type = UniformLayerAuxKernel variable = layer_id interfaces = '1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20.2' direction = '0.0 0.0 1.0' execute_on = initial [../] []

[BCs] [./bottom_z] type = PresetBC variable = disp_z boundary = 'back' value = 0.0 [../] [./bottom_y] type = PresetBC variable = disp_y boundary = 'back' value = 0.0 [../] [./bottom_accel] type = PresetAcceleration boundary = 'back' function = accel_bottom variable = 'disp_x' beta = 0.25 acceleration = 'accel_x' velocity = 'vel_x' [../] [./Periodic] [./y_dir] variable = 'disp_x disp_y disp_z' primary = 'bottom' secondary = 'top' translation = '0.0 1.0 0.0' [../] [./x_dir] variable = 'disp_x disp_y disp_z' primary = 'left' secondary = 'right' translation = '1.0 0.0 0.0' [../] [../] []

[Functions] [./accel_bottom] type = PiecewiseLinear data_file = chichi_bc_mpss_xp20.csv format = 'columns' [../] [./initial_zz] type = ParsedFunction value = '-2000.0 9.81 (20.0 - z)' [../] [./initial_xx] type = ParsedFunction value = '-2000.0 9.81 (20.0 - z) * 0.3/0.7' [../] []

[Materials] [./soil_all] block = 0 layer_variable = layer_id layer_ids = '0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19' initial_soil_stress = 'initial_xx 0 0 0 initial_xx 0 0 0 initial_zz' poissons_ratio = '0.3 0.3 0.3 0.3 0.3 0.3 0.3 0.3 0.3 0.3 0.3 0.3 0.3 0.3 0.3 0.3 0.3 0.3 0.3 0.3' type = ADComputeISoilStress soil_type = 'gqh' number_of_points = 100

GQ/H

initial_shear_modulus = '125000000 118098000 111392000 103968000 96800000 89888000 83232000 76832000 70688000 64800000 59168000 53792000 48672000 43808000 39200000 34848000 30752000 26912000 23328000 20000000' theta_1 = '-6.66 -6.86 -7.06 -7.35 -7.65 -7.95 -8.3 -8.61 -8.95 -9.3 -9.61 -9.92 -10.0 -10.0 -10.0 -10.0 -10.0 -9.31 -7.17 -5.54' theta_2 = '5.5 5.7 5.9 6.2 6.6 6.9 7.3 7.6 8.0 8.4 8.6 8.8 8.82 8.71 8.55 8.3 7.88 6.4 2.4 -2.28' theta_3 = '1.0 1.0 1.0 1.0 1.0 1.0 1.0 1.0 1.0 1.0 1.0 1.0 1.0 1.0 1.0 1.0 1.0 1.0 1.0 1.0' theta_4 = '1.0 1.0 1.0 1.0 1.0 1.0 1.0 1.0 1.0 1.0 1.0 1.0 1.0 1.0 1.0 1.0 1.0 1.0 1.0 1.0' theta_5 = '0.99 0.99 0.99 0.99 0.99 0.99 0.99 0.99 0.99 0.99 0.99 0.99 0.99 0.99 0.99 0.99 0.99 0.99 0.99 0.99' taumax = '292500 277500 262500 247500 232500 217500 202500 187500 172500 157500 142500 127500 112500 97500 82500 67500 52500 37500 22500 7500' p_ref = '236841 224695 212550 200404 188258 176112 163967 151821 139675 127530 115384 103238 91092 78947 66801 54655 42510 30364 18218 6072'

a0 = 1.0 a1 = 0.0 a2 = 0.0 b_exp = 0.0 [../] [./sample_isoil_strain] type = ADComputeIncrementalSmallStrain block = 0 displacements = 'disp_x disp_y disp_z' [../] [./sample_isoil_elasticitytensor] type = ComputeIsotropicElasticityTensorSoil block = 0 elastic_modulus = '325000000 307054800 289619200 270316800 251680000 233708800 216403200 199763200 183788800 168480000 153836800 139859200 126547200 113900800 101920000 90604800 79955200 69971200 60652800 52000000' poissons_ratio = '0.3 0.3 0.3 0.3 0.3 0.3 0.3 0.3 0.3 0.3 0.3 0.3 0.3 0.3 0.3 0.3 0.3 0.3 0.3 0.3' density = '2000.0 2000.0 2000.0 2000.0 2000.0 2000.0 2000.0 2000.0 2000.0 2000.0 2000.0 2000.0 2000.0 2000.0 2000.0 2000.0 2000.0 2000.0 2000.0 2000.0' wave_speed_calculation = false layer_ids = '0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19' layer_variable = layer_id [../] []

[Preconditioning] [./andy] type = SMP full = true [../] []

[Executioner] type = Transient solve_type = NEWTON nl_abs_tol = 1e-6 nl_rel_tol = 1e-6 start_time = 0 end_time = 85.4 dt = 0.01 timestep_tolerance = 1e-6 petsc_options = '-snes_check_jacobian' []

[Postprocessors] [./accelx_top] type = PointValue point = '0.0 0.0 20.0' variable = accel_x [../] [./accelx_top1] type = PointValue point = '0.0 0.0 19.0' variable = accel_x [../] [./accelx_mid] type = PointValue point = '0.0 0.0 10.0' variable = accel_x [../] [./accelx_bot] type = PointValue point = '0.0 0.0 0.0' variable = accel_x [../] []

[Outputs] csv = true exodus = true perf_graph = true print_linear_residuals = false [./screen] type = Console max_rows = 1 interval = 1000 [../] []

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/idaholab/mastodon/issues/238?email_source=notifications&email_token=ACQ6BU7VMZMQGWO6P4ASMA3QHBDO3A5CNFSM4IN25CNKYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOD5P7TLQ#issuecomment-526383534, or mute the thread https://github.com/notifications/unsubscribe-auth/ACQ6BU4CVVJ45DIPLYIJQKLQHBDO3ANCNFSM4IN25CNA .

-- Sent from Mobile

somu15 commented 4 years ago

Yes, the code I wrote seems to run slowly than using non-AD.

cbolisetti commented 4 years ago

What if you removed the snes-check-jacobian option?

On Tue, Sep 3, 2019 at 6:40 AM Som Dhulipala notifications@github.com wrote:

Yes, the code I wrote seems to run slowly than using non-AD.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/idaholab/mastodon/issues/238?email_source=notifications&email_token=ACQ6BU26PI4SPJ7IMZYZKQTQHZLNPA5CNFSM4IN25CNKYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOD5YBVXA#issuecomment-527440604, or mute the thread https://github.com/notifications/unsubscribe-auth/ACQ6BU5QSK2AZ5HHA5AEXWLQHZLNPANCNFSM4IN25CNA .

-- Sent from Mobile

somu15 commented 4 years ago

It doesn't seem to make much difference. However, I can run the entire ground motion and get the exact run time for comparison.

sveerara commented 4 years ago

Sorry, I am a little late to this conversation. Is there a conclusion on the timing analysis for this problem with/without AD?

somu15 commented 4 years ago

Swetha, Attached are the perf-graph outputs for AD and no-AD.

With AD: AD

Without AD: NO_AD