$
$*********************************************      basics
$
&dimen -save -dimen meters m-tons
&device -oecho no -g_default file
&default -gravity 9.81*0.001 $reduce gravity to obtain constant velocity
&title 'MOSES slamming for comparison to OMAE2005-67311'
&set diam = 0.125
$
$*********************************************      read model
$
inmodel
&apply -fraction -category tube #dead 100000
&parameter -slam_both no
$*********************************************      water entry
&loop veloc (0.5124 0.639 0.760 0.876 1.024)
  &instate -locate tube 0 0 0 -vel 0 0 -%veloc
  &set t_end = 6*0.5*%(diam)/%(veloc)  $end simulation when V*t/R=6
  &set t_step = 0.001
  &env -time %t_end %t_step
  &set v_r = %(veloc)*2/%(diam)
  &set coeff = &number(real 0.5*1025*%(veloc)**2*%(diam))
  &set coeff2 = 9810.0/%(coeff)
  tdom
  prcpost
    body *tubem -force @ -body tube
      add_column vt_r -combine 1 %v_r $add column for Vt/R, id 135
      add_column buoy -combine 18 1000 $scale buoyancy to account for reduced gravity, id 136
      add_column tot -combine 136 1 32 1 46 1 $add column for combination of buoyancy, drag and slam, id 137
      add_column cs_tot -combine 137 %coeff2 $add column for Cs=F/(.5*rho*v^2*D) id 138
      add_column cs_buoy -combine 136 %coeff2 $non-dim buoy, id 139
      add_column cs_slam -combine 46 %coeff2 $non-dim slam, id 140
      add_column cs_drag -combine 32 %coeff2 $non-dim drag, id 141
      range -x 0 5
      plot 135 138 140 141 139 \
      -t_sub 'Water entry with constant velocity = %veloc' \
      -t_left 'Cs' \
      -t_x 'Vt/R' \
      -no_edit
      store 135 138 -heading 'Water entry with constant velocity = %veloc'
    end $disposition
  end $prcpost
&endloop $veloc
$*********************************************      water exit
&loop veloc (0.5124 0.7644)
  &set t_end = 10*0.5*%(diam)/%(veloc)  $end simulation when V*t/R=10
  &set t_free = 0.5*%t_end $time at which the entire cylinder is above mwl
  &set t_step = 0.001
  &set h_start = %(veloc)*%(t_free)-%(diam)
  &instate -locate tube 0 0 -1*%h_start -vel 0 0 %veloc
  &env -time %t_end %t_step
  &set v_r = &number(real %(veloc)*2/%(diam))
  &set coeff = &number(real 0.5*1025*%(veloc)**2*%(diam))
  &set coeff2 = &number(real 9810.0/%(coeff))
  tdom
  prcpost
    body *tubem -force @ -body tube
      $set_variable nrows -num_rows
      $&set col = &string(repeat -5.0 %nrows)
      $&type %nrows
      $&type &token(n %col)
      add_column const -input 1 -1000 -5 1000 -5  $dummy column for translating non-dim time, id 135
      add_column vt_r -combine 1 %v_r 135 1  $add column for Vt/R and translate -5, id 136
      add_column buoy -combine 18 1000 $scale buoyancy to account for reduced gravity, id 137
      add_column tot -combine 137 1 32 1 46 1 $add column for combination of buoyancy, drag and slam, id 138
      add_column ce_tot -combine 138 %coeff2 $add column for Cs=F/(.5*rho*v^2*D) id 139
      add_column ce_buoy -combine 137 %coeff2 $non-dim buoy, id 140
      add_column ce_slam -combine 46 %coeff2 $non-dim slam, id 141
      add_column ce_drag -combine 32 %coeff2 $non-dim drag, id 142
      add_column ce_tot_x -combine 140 1 142 1  $non-dim drag+buoy, id 143
      vlist
      range -x -5 5
      plot 136 139 141 142 140 143 \
      -t_sub 'Water exit with constant velocity = %veloc' \
      -t_left 'Ce' \
      -t_x 'Vt/R' \
      -no_edit
      store 136 139 143 -heading 'Water exit with constant velocity = %veloc'
    end $disposition
  end $prcpost
&endloop $veloc
&fini
