close all
clear all

name = 'DelMar_hamilton_v1';


  LAYOUT.title = name;
  
  ENV.depth = 100;
  ENV.tf = 330; 
  ENV.ramptime = 30;




  ENV.xwaveamp = 1.5;
  ENV.xwaveperiod = 10;
  ENV.xwavephase = 0;
  ENV.xwind = 8;

  ENV.currentscale = 1;
  ENV.xcurrent = NaN(3,2);
  ENV.xcurrent(1,:) = [0 0.515];
  ENV.xcurrent(2,:) = [20 0.515];
  ENV.xcurrent(3,:) = [100 0.1];

  ENV.dynamiclambda = -0.5;
 
  ENV.forcing_type =  'wave-follower'; %'velocity';  % -or- 'wave-follower'
 
  ENV.input_type = 'random';  % regular -or- 'random'

  LAYOUT.config = 1;  %1 = Catenary w/ stretch hose
		      %2 = Catenary w/ EM Chain
		      %3 = Taut w/ stretch hose
  
  for LAYOUT.config = [1 2 3]
  
   LAYOUT.config

  ENV.dt = 0.04;
  if(LAYOUT.config == 2)
	ENV.dt = 0.01;
  end

 
   filenm = make_layout(ENV,LAYOUT,name)


    cpp_cmd = ['cpp ' name '.cab ' filenm '.cab'];
    system(cpp_cmd);

    bom_cmd = ['cable -in ' filenm '.cab -out ' filenm '.bom -bom'];
    system(bom_cmd);

    [seg_name seg_length seg_n_nodes seg_nodes] = read_bom(filenm);

    cable_cmd = ['cable -in ' filenm '.cab -out ' filenm '.res -nodes '];
    cable_cmd = [cable_cmd num2str(1) ' '];  %List the anchor node specifically instead of using '-first -last'
    for n = length(seg_nodes):-1:1
      cable_cmd = [cable_cmd num2str(seg_nodes(n)) ' '];
    end
    cable_cmd = [cable_cmd ' -snap_dt 1 -sample ' num2str(ENV.dt) ' -quit'];
    cable_cmd = [cable_cmd ' | tee ' filenm '.out'];

    system(['echo ' cable_cmd ' > ' filenm '.cmd']);

    system(cable_cmd);

    res2mat_cmd = ['res2mat -in ' filenm '.res -out ' filenm '.mat -lbs -totals'];
    system(res2mat_cmd);

   end


    load([filenm '.mat']);

 





