;DTU_10MW_RWT, version 5, 04-21-15, anyd
;
  begin simulation;
    time_stop	{{time_stop}};
    solvertype	1;		(newmark)
    on_no_convergence	continue;
    convergence_limits	1000 1 1e-07;
    logfile	./log/{{Name}}.log;
    begin newmark;
      deltat	0.02;
    end newmark;
  end simulation;		;
;----------------------------------------------------------------------------------------------------------------------------------------------------------------
  begin new_htc_structure;		;   beam_output_file_name  ./log/DTU_10MW_RWT_beam.dat;                    Optional - Calculated beam properties of the bodies are written to file
;   body_output_file_name  ./log/DTU_10MW_RWT_body.dat;                    Optional - Body initial position and orientation are written to file
;   body_eigenanalysis_file_name ./eig/DTU_10MW_RWT_body_eigen.dat;
;   structure_eigenanalysis_file_name ./eig/DTU_10MW_RWT_strc_eigen.dat ;
;-------------------------------------------------------------------------------------------------------------------------------
;-------------------------------------------------------------------------------------------------------------------------------
    begin main_body;		tower 115m
      name	tower;
      type	timoschenko;
      nbodies	1;
      node_distribution	c2_def;
      damping_posdef	0 0 0 0.00412 0.00412 0.00045;		Mx My Mz Kx Ky Kz , MÃ‚Â´s raises overall level, KÃ‚Â´s raises high freguency level "tuned by Larh"
      begin timoschenko_input;
        filename	./data/dtu_10mw_rwt_tower_st.dat;
        set	1 1;
      end timoschenko_input;
      begin c2_def;		Definition of centerline (main_body coordinates)
        nsec	11;
        sec	1 0 0 0 0;		x,y,z,twist
        sec	2 0 0 -11.5 0;
        sec	3 0 0 -23 0;
        sec	4 0 0 -34.5 0;
        sec	5 0 0 -46 0;
        sec	6 0 0 -57.5 0;
        sec	7 0 0 -69 0;
        sec	8 0 0 -80.5 0;
        sec	9 0 0 -92 0;
        sec	10 0 0 -103.5 0;
        sec	11 0 0 -115.63 0;
      end c2_def;
    end main_body;		;
    begin main_body;
      name	towertop;
      type	timoschenko;
      nbodies	1;
      node_distribution	c2_def;
      damping_posdef	0 0 0 0.007 0.007 0.007;		"changed by Larh"
      concentrated_mass	2 0 2.687 0.30061 446040 4106000 410600 4106000;		Nacelle mass and inertia "corrected by Anyd 25/4/13"
      begin timoschenko_input;
        filename	./data/dtu_10mw_rwt_towertop_st.dat;
        set	1 2;
      end timoschenko_input;
      begin c2_def;		Definition of centerline (main_body coordinates)
        nsec	2;
        sec	1 0 0 0 0;		x,y,z,twist
        sec	2 0 0 -2.75 0;
      end c2_def;
    end main_body;		;
    begin main_body;
      name	shaft;
      type	timoschenko;
      nbodies	1;
      node_distribution	c2_def;
      damping_posdef	0 0 0 0.000465 0.000465 0.003983;		"tuned by Anyd 23/5/13 to 31.45 log decr. damping for free free with stiff rotor and tower"
      concentrated_mass	1 0 0 0 0 0 0 3751000;		generator equivalent slow shaft "re_tuned by Anyd 20/2/13"
      concentrated_mass	5 0 0 0 105520 0 0 325700;		hub mass and inertia;	"re_tuned by Anyd 20/2/13"
      begin timoschenko_input;
        filename	./data/dtu_10mw_rwt_shaft_st.dat;
        set	1 1;
      end timoschenko_input;
      begin c2_def;		Definition of centerline (main_body coordinates)
        nsec	5;
        sec	1 0 0 0 0;		Tower top x,y,z,twist
        sec	2 0 0 1.5 0;
        sec	3 0 0 3 0;
        sec	4 0 0 4.4 0;		Main bearing
        sec	5 0 0 7.1 0;		Rotor centre
      end c2_def;
    end main_body;		;
    begin main_body;
      name	hub1;
      type	timoschenko;
      nbodies	1;
      node_distribution	c2_def;
      damping_posdef	0 0 0 3e-06 3e-06 2e-05;		"changed by Larh"
      begin timoschenko_input;
        filename	./data/dtu_10mw_rwt_hub_st.dat;
        set	1 2;
      end timoschenko_input;
      begin c2_def;		Definition of centerline (main_body coordinates)
        nsec	2;
        sec	1 0 0 0 0;		x,y,z,twist
        sec	2 0 0 2.8 0;
      end c2_def;
    end main_body;		;
    begin main_body;
      name	hub2;
      copy_main_body	hub1;
    end main_body;		;
    begin main_body;
      name	hub3;
      copy_main_body	hub1;
    end main_body;		;
    begin main_body;
      name	blade1;
      type	timoschenko;
      nbodies	10;
      node_distribution	c2_def;
      damping_posdef	0 0 0 0.00153 0.00255 0.00033;		" 3% damping tuned by tkim 23/03/13 unable to fit 3rd and higher mode"
      begin timoschenko_input;
        filename	./data/dtu_10mw_rwt_blade_st.dat;
        set	1 1;		set subset
      end timoschenko_input;
      begin c2_def;		Definition of centerline (main_body coordinates)
        nsec	27;
        sec	1 0 7.006e-05 4.44089e-16 -14.5;
        sec	2 -2.06477e-05 -0.0122119 3 -14.5;
        sec	3 -0.0072881 -0.0249251 6 -14.4851;
        sec	4 -0.0189235 -0.0273351 7.00004 -14.461;
        sec	5 -0.0541282 -0.0282163 8.70051 -14.3388;
        sec	6 -0.126633 -0.021321 10.402 -14.0201;
        sec	7 -0.225666 -0.0128378 12.2046 -13.3904;
        sec	8 -0.288563 -0.00770659 13.2065 -12.9371;
        sec	9 -0.399194 -0.00488317 15.01 -11.9445;
        sec	10 -0.576634 -0.0180296 18.2151 -9.98243;
        sec	11 -0.707136 -0.0501772 21.4178 -8.45147;
        sec	12 -0.791081 -0.0941228 24.6189 -7.46417;
        sec	13 -0.837195 -0.14888 27.8193 -6.72916;
        sec	14 -0.853948 -0.214514 31.0194 -6.08842;
        sec	15 -0.849367 -0.290618 34.2197 -5.49322;
        sec	16 -0.79392 -0.462574 40.2204 -4.39222;
        sec	17 -0.716284 -0.688437 46.6217 -3.09315;
        sec	18 -0.634358 -0.960017 53.0232 -1.75629;
        sec	19 -0.553179 -1.28424 59.4245 -0.50065;
        sec	20 -0.475422 -1.66402 65.8255 0.601964;
        sec	21 -0.40318 -2.10743 72.2261 1.5556;
        sec	22 -0.330085 -2.6563 79.0266 2.51935;
        sec	23 -0.31014 -2.78882 80.5267 2.7295;
        sec	24 -0.286719 -2.92517 82.0271 2.93201;
        sec	25 -0.255823 -3.06577 83.5274 3.11874;
        sec	26 -0.207891 -3.20952 85.0277 3.28847;
        sec	27 -0.089894 -3.33685 86.3655 3.42796;
      end c2_def;
    end main_body;		;
    begin main_body;
      name	blade2;
      copy_main_body	blade1;
    end main_body;		;
    begin main_body;
      name	blade3;
      copy_main_body	blade1;
    end main_body;		;-------------------------------------------------------------------------------------------------------------------------------
;
    begin orientation;
      begin base;
        body	tower;
        inipos	0 0 0;		initial position of node 1
        body_eulerang	0 0 0;
      end base;		;
      begin relative;
        body1	tower last;
        body2	towertop 1;
        body2_eulerang	0 0 0;
      end relative;		;
      begin relative;
        body1	towertop last;
        body2	shaft 1;
        body2_eulerang	90 0 0;
        body2_eulerang	5 0 0;		5 deg tilt angle
        body2_eulerang	0 0 0;
        mbdy2_ini_rotvec_d1	0 0 -1 0.7;		mbdy2_ini_rotvec_d1 0.0 0.0 -1.0 [init_wr];
      end relative;		;
      begin relative;
        body1	shaft last;
        body2	hub1 1;
        body2_eulerang	-90 0 0;
        body2_eulerang	0 180 0;
        body2_eulerang	2.5 0 0;		2.5deg cone angle
      end relative;		;
      begin relative;
        body1	shaft last;
        body2	hub2 1;
        body2_eulerang	-90 0 0;
        body2_eulerang	0 60 0;
        body2_eulerang	2.5 0 0;		2.5deg cone angle
      end relative;		;
      begin relative;
        body1	shaft last;
        body2	hub3 1;
        body2_eulerang	-90 0 0;
        body2_eulerang	0 -60 0;
        body2_eulerang	2.5 0 0;		2.5deg cone angle
      end relative;		;
      begin relative;
        body1	hub1 last;
        body2	blade1 1;
        body2_eulerang	0 0 0;
      end relative;		;
      begin relative;
        body1	hub2 last;
        body2	blade2 1;
        body2_eulerang	0 0 0;
      end relative;		;
      begin relative;
        body1	hub3 last;
        body2	blade3 1;
        body2_eulerang	0 0 0;
      end relative;		;
    end orientation;		;-------------------------------------------------------------------------------------------------------------------------------
    begin constraint;		;
      begin fix0;		fixed to ground in translation and rotation of node 1
        body	tower;
      end fix0;		;
      begin fix1;
        body1	tower last;
        body2	towertop 1;
      end fix1;		;
      begin bearing1;		free bearing
        name	shaft_rot;
        body1	towertop last;
        body2	shaft 1;
        bearing_vector	2 0 0 -1;		x=coo (0=global.1=body1.2=body2) vector in body2 coordinates where the free rotation is present
      end bearing1;		;
      begin fix1;
        body1	shaft last;
        body2	hub1 1;
      end fix1;		;
      begin fix1;
        body1	shaft last;
        body2	hub2 1;
      end fix1;		;
      begin fix1;
        body1	shaft last;
        body2	hub3 1;
      end fix1;		;
      begin bearing2;
        name	pitch1;
        body1	hub1 last;
        body2	blade1 1;
        bearing_vector	2 0 0 -1;
      end bearing2;		;
      begin bearing2;
        name	pitch2;
        body1	hub2 last;
        body2	blade2 1;
        bearing_vector	2 0 0 -1;
      end bearing2;		;
      begin bearing2;
        name	pitch3;
        body1	hub3 last;
        body2	blade3 1;
        bearing_vector	2 0 0 -1;
      end bearing2;
    end constraint;		;
  end new_htc_structure;		;----------------------------------------------------------------------------------------------------------------------------------------------------------------
  begin wind;
    density	1.225;
    wsp	{{wsp}};
    tint	{{tint}};
    horizontal_input	1;
    windfield_rotations	0 0 0;		yaw, tilt, rotation
    center_pos0	0 0 -119;		hub heigth
    shear_format	1 0.2;
    turb_format	1;		0=none, 1=mann,2=flex
    tower_shadow_method	0;		0=none, 1=potential flow, 2=jet
    scale_time_start	0;
    wind_ramp_factor	0 40 0.6 1;		; Steps ;
    wind_ramp_abs	140 141 0 1;		wsp. after the step:  5.0
    wind_ramp_abs	181 182 0 1;		wsp. after the step:  6.0
    wind_ramp_abs	222 223 0 1;		wsp. after the step:  7.0
    wind_ramp_abs	263 264 0 1;		wsp. after the step:  8.0
    wind_ramp_abs	304 305 0 1;		wsp. after the step:  9.0
    wind_ramp_abs	345 346 0 1;		wsp. after the step: 10.0
    wind_ramp_abs	386 387 0 1;		wsp. after the step: 11.0
    wind_ramp_abs	427 428 0 1;		wsp. after the step: 12.0
    wind_ramp_abs	468 469 0 1;		wsp. after the step: 13.0
    wind_ramp_abs	509 510 0 1;		wsp. after the step: 14.0
    wind_ramp_abs	550 551 0 1;		wsp. after the step: 15.0
    wind_ramp_abs	591 592 0 1;		wsp. after the step: 16.0
    wind_ramp_abs	632 633 0 1;		wsp. after the step: 17.0
    wind_ramp_abs	673 674 0 1;		wsp. after the step: 18.0
    wind_ramp_abs	714 715 0 1;		wsp. after the step: 19.0
    wind_ramp_abs	755 756 0 1;		wsp. after the step: 20.0
    wind_ramp_abs	796 797 0 1;		wsp. after the step: 21.0
    wind_ramp_abs	837 838 0 1;		wsp. after the step: 22.0
    wind_ramp_abs	878 879 0 1;		wsp. after the step: 23.0
    wind_ramp_abs	919 920 0 1;		wsp. after the step: 24.0
    wind_ramp_abs	960 961 0 1;		wsp. after the step: 25.0
;
    begin tower_shadow_potential_2;
      tower_mbdy_link	tower;
      nsec	2;
      radius	0 4.15;
      radius	115.63 2.75;
    end tower_shadow_potential_2;
  end wind;		;
  begin aerodrag;
    begin aerodrag_element;
      mbdy_name	tower;
      aerodrag_sections	uniform 10;
      nsec	2;
      sec	0 0.6 8.3;		tower bottom
      sec	115.63 0.6 5.5;		tower top
    end aerodrag_element;		;
    begin aerodrag_element;		Nacelle drag side
      mbdy_name	shaft;
      aerodrag_sections	uniform 2;
      nsec	2;
      sec	0 0.8 10;
      sec	7.01 0.8 10;
    end aerodrag_element;
  end aerodrag;		;
  begin aero;
    nblades	3;
    hub_vec	shaft -3;		rotor rotation vector (normally shaft composant directed from pressure to sustion side)
    link	1 mbdy_c2_def blade1;
    link	2 mbdy_c2_def blade2;
    link	3 mbdy_c2_def blade3;
    ae_filename	./data/dtu_10mw_rwt_ae.dat;
    pc_filename	./data/dtu_10mw_rwt_pc.dat;
    induction_method	1;		0=none, 1=normal
    aerocalc_method	1;		0=ingen aerodynamic, 1=med aerodynamic
    aerosections	50;		def. 50
    ae_sets	1 1 1;
    tiploss_method	1;		0=none, 1=prandtl
    dynstall_method	2;		0=none, 1=stig ÃƒÂ¸ye method,2=mhh method
;
  end aero;		;-------------------------------------------------------------------------------------------------
  begin dll;		;
    begin type2_dll;
      name	risoe_controller;
      filename	./control/dtu_we_controller.dll;
      dll_subroutine_init	init_regulation;
      dll_subroutine_update	update_regulation;
      arraysizes_init	52 1;
      arraysizes_update	12 100;
      begin init;		; Overall parameters
        constant	1 10000;		Rated power [kW]
        constant	2 0.5236;		Minimum rotor speed [rad/s]
        constant	3 1.005;		Rated rotor speed [rad/s]
        constant	4 15600000;		Maximum allowable generator torque [Nm]
        constant	5 100;		Minimum pitch angle, theta_min [deg],
; if |theta_min|>90, then a table of <wsp,theta_min> is read ;
; from a file named 'wptable.n', where n=int(theta_min)
        constant	6 82;		Maximum pitch angle [deg]
        constant	7 10;		Maximum pitch velocity operation [deg/s]
        constant	8 0.4;		Frequency of generator speed filter [Hz]
        constant	9 0.7;		Damping ratio of speed filter [-]
        constant	10 1.92;		Frequency of free-free DT torsion mode [Hz], if zero no notch filter used
; Partial load control parameters
        constant	11 11750000;		Optimal Cp tracking K factor [Nm/(rad/s)^2], ;
; Qg=K*Omega^2, K=eta*0.5*rho*A*Cp_opt*R^3/lambda_opt^3
        constant	12 70840000;		Proportional gain of torque controller [Nm/(rad/s)]
        constant	13 15900000;		Integral gain of torque controller [Nm/rad]
        constant	14 0;		Differential gain of torque controller [Nm/(rad/s^2)]
;     Full load control parameters
        constant	15 2;		Generator control switch [1=constant power, 2=constant torque]
        constant	16 1.304;		Proportional gain of pitch controller [rad/(rad/s)]
        constant	17 0.3511;		Integral gain of pitch controller [rad/rad]
        constant	18 0;		Differential gain of pitch controller [rad/(rad/s^2)]
        constant	19 4e-09;		Proportional power error gain [rad/W]
        constant	20 4e-09;		Integral power error gain [rad/(Ws)]
        constant	21 11.35;		Coefficient of linear term in aerodynamic gain scheduling, KK1 [deg]
        constant	22 400.7;		Coefficient of quadratic term in aerodynamic gain scheduling, KK2 [deg^2] &
; (if zero, KK1 = pitch angle at double gain)
        constant	23 1.3;		Relative speed for double nonlinear gain [-]
;     Cut-in simulation parameters
        constant	24 -1;		Cut-in time [s]
        constant	25 1;		Time delay for soft start of torque [1/1P]
;     Cut-out simulation parameters
        constant	26 1500;		Cut-out time [s]
        constant	27 5;		Time constant for linear torque cut-out [s]
        constant	28 1;		Stop type [1=normal, 2=emergency]
        constant	29 1;		Time delay for pitch stop after shut-down signal [s]
        constant	30 3;		Maximum pitch velocity during initial period of stop [deg/s]
        constant	31 3;		Time period of initial pitch stop phase [s] (maintains pitch speed specified in constant 30)
        constant	32 4;		Maximum pitch velocity during final phase of stop [deg/s]
;     Expert parameters (keep default values unless otherwise given)
        constant	33 2;		Lower angle above lowest minimum pitch angle for switch [deg]
        constant	34 2;		Upper angle above lowest minimum pitch angle for switch [deg], if equal then hard switch
        constant	35 95;		Ratio between filtered speed and reference speed for fully open torque limits [%]
        constant	36 2;		Time constant of 1st order filter on wind speed used for minimum pitch [1/1P]
        constant	37 1;		Time constant of 1st order filter on pitch angle used for gain scheduling [1/1P]
;     Drivetrain damper
        constant	38 0;		Proportional gain of active DT damper [Nm/(rad/s)], requires frequency in input 10
;	  Over speed
        constant	39 25;		Overspeed percentage before initiating turbine controller alarm (shut-down) [%]
;     Additional non-linear pitch control term (not used when all zero)
        constant	40 0;		Err0 [rad/s]
        constant	41 0;		ErrDot0 [rad/s^2]
        constant	42 0;		PitNonLin1 [rad/s]
;     Storm control command
        constant	43 28;		Wind speed 'Vstorm' above which derating of rotor speed is used [m/s]
        constant	44 28;		Cut-out wind speed (only used for derating of rotor speed in storm) [m/s]
;     Safety system parameters
        constant	45 300;		Overspeed percentage before initiating safety system alarm (shut-down) [%]
        constant	46 1.5;		Max low-pass filtered tower top acceleration level [m/s^2]
;     Turbine parameter
        constant	47 178;		Nominal rotor diameter [m]
;     Parameters for rotor inertia reduction in variable speed region
        constant	48 0;		Proportional gain on rotor acceleration in variable speed region [Nm/(rad/s^2)] (not used when zero)
;     Parameters for alternative partial load controller with PI regulated TSR tracking
        constant	49 0;		Optimal tip speed ratio [-] (only used when K=constant 11 = 0 otherwise  Qg=K*Omega^2 is used)
;     Parameters for adding aerodynamic drivetrain damping on gain scheduling
        constant	50 0;		Proportional gain of aerodynamic DT damping [Nm/(rad/s)]
        constant	51 0;		Coefficient of linear term in aerodynamic DT damping scheduling, KK1 [deg]
        constant	52 0;		Coefficient of quadratic term in aerodynamic DT damping scheduling, KK2 [deg^2]
      end init;		;
      begin output;
        general time;						 [s]
        constraint bearing1	shaft_rot 1 only 2;						 Drivetrain speed [rad/s]
        constraint bearing2	pitch1 1 only 1;						 [rad]
        constraint bearing2	pitch2 1 only 1;						 [rad]
        constraint bearing2	pitch3 1 only 1;						 [rad]
        wind free_wind	1 0 0 -119;						 Global coordinates at hub height
        dll inpvec	2 2;						 Elec. power from generator servo .dll
        dll inpvec	2 8;						 Grid state flag from generator servo .dll
        mbdy state	acc tower 10 1 global only 1;						 Tower top x-acceleration [m/s^2]
        mbdy state	acc tower 10 1 global only 2;						 Tower top y-acceleration [m/s^2]
      end output;
    end type2_dll;		;
    begin type2_dll;
      name	generator_servo;
      filename	./control/generator_servo.dll;
      dll_subroutine_init	init_generator_servo;
      dll_subroutine_update	update_generator_servo;
      arraysizes_init	7 1;
      arraysizes_update	4 8;
      begin init;
        constant	1 20;		Frequency of 2nd order servo model of generator-converter system [Hz]
        constant	2 0.9;		Damping ratio 2nd order servo model of generator-converter system [-]
        constant	3 15600000;		Maximum allowable LSS torque (pull-out torque) [Nm]
        constant	4 0.94;		Generator efficiency [-]
        constant	5 1;		Gearratio [-]
        constant	6 0;		Time for half value in softstart of torque [s]
        constant	7 1500;		Time for grid loss [s]
      end init;		;
      begin output;
        general time;						 Time [s]
        dll inpvec	1 1;						 Electrical torque reference [Nm]
        constraint bearing1	shaft_rot 1 only 2;						 Generator LSS speed [rad/s]
        mbdy momentvec	shaft 1 1 shaft only 3;						 Shaft moment [kNm] (Qshaft)
      end output;	
;
      begin actions;
        mbdy	moment_int shaft 1 -3 shaft towertop 2;		Generator LSS torque [Nm]
      end actions;
    end type2_dll;		;
    begin type2_dll;
      name	mech_brake;
      filename	./control/mech_brake.dll;
      dll_subroutine_init	init_mech_brake;
      dll_subroutine_update	update_mech_brake;
      arraysizes_init	7 1;
      arraysizes_update	4 6;
      begin init;
        constant	1 2727252;		Fully deployed maximum brake torque [Nm]
        constant	2 100;		Parameter alpha used in Q = tanh(omega*alpha), typically 1e2/Omega_nom
        constant	3 0.625;		Delay time for before brake starts to deploy [s] - from 5MW*1P_5/1P_10
        constant	4 0.75;		Time for brake to become fully deployed [s]
      end init;		;
      begin output;
        general time;						 Time [s]
        constraint bearing1	shaft_rot 1 only 2;						 Generator LSS speed [rad/s]
        dll inpvec	1 25;						 Command to deploy mechanical disc brake [0,1]
      end output;	
;
      begin actions;
        mbdy	moment_int shaft 1 3 shaft towertop 2;		Brake LSS torque [Nm]
      end actions;
    end type2_dll;		;
    begin type2_dll;
      name	servo_with_limits;
      filename	./control/servo_with_limits.dll;
      dll_subroutine_init	init_servo_with_limits;
      dll_subroutine_update	update_servo_with_limits;
      arraysizes_init	10 1;
      arraysizes_update	5 9;
      begin init;
        constant	1 3;		Number of blades [-]
        constant	2 1;		Frequency of 2nd order servo model of pitch system [Hz]
        constant	3 0.7;		Damping ratio 2nd order servo model of pitch system [-]
        constant	4 10;		Max. pitch speed [deg/s]
        constant	5 15;		Max. pitch acceleration [deg/s^2]
        constant	6 -5;		Min. pitch angle [deg]
        constant	7 90;		Max. pitch angle [deg]
        constant	8 1500;		Time for pitch runaway [s]
        constant	9 1500;		Time for stuck blade 1 [s]
        constant	10 0;		Angle of stuck blade 1 [deg]
      end init;
      begin output;
        general time;						  Time                         [s]
        dll inpvec	1 2;						  Pitch1 demand angle          [rad]
        dll inpvec	1 3;						  Pitch2 demand angle          [rad]
        dll inpvec	1 4;						  Pitch3 demand angle          [rad]
        dll inpvec	1 26;						  Flag for emergency pitch stop         [0=off/1=on]
      end output;	
;
      begin actions;
        constraint	bearing2 angle pitch1;		Angle pitch1 bearing    [rad]
        constraint	bearing2 angle pitch2;		Angle pitch2 bearing    [rad]
        constraint	bearing2 angle pitch3;		Angle pitch3 bearing    [rad]
      end actions;
    end type2_dll;		;
;	--- DLL for tower-blade tip distance -- ;
    begin type2_dll;
      name	disttowtip;
      filename	./control/towclearsens.dll;
      dll_subroutine_init	initialize;
      dll_subroutine_update	update;
      arraysizes_init	1 1;
      arraysizes_update	12 4;
      begin init;
        constant	1 2.66;		Tower radius close to downward blade tip [m]
      end init;
      begin output;
        mbdy state	pos tower 3 0.62 global;						 [1,2,3]. Tower position: 30.18 m
        mbdy state	pos blade1 26 1 global;						 [4,5,6]
        mbdy state	pos blade2 26 1 global;						 [7,8,9]
        mbdy state	pos blade3 26 1 global;						 [10,11,12]
      end output;
    end type2_dll;
  end dll;		;----------------------------------------------------------------------------------------------------------------------------------------------------------------
;
  begin output;
    filename	./res/{{Name}};		; time 99.0 1000.0 ;
; data_format  hawc_ascii;
    data_format	hawc_binary;
    buffer	1;		;
    general time;
    constraint bearing1	shaft_rot 2;			 angle and angle velocity
    constraint bearing2	pitch1 5;			    angle and angle velocity
    constraint bearing2	pitch2 5;			    angle and angle velocity
    constraint bearing2	pitch3 5;			    angle and angle velocity
    aero omega;
    aero torque;
    aero power;
    aero thrust;
    wind free_wind	1 0 0 -119;			 local wind at fixed position: coo (1=global,2=non-rotation rotor coo.), pos x, pos y, pos z
; Moments:
    mbdy momentvec	tower 1 1 tower # tower base;
    mbdy momentvec	tower 10 2 tower # tower yaw bearing;
    mbdy momentvec	shaft 4 1 shaft # main bearing;
    mbdy momentvec	blade1 2 2 blade1 # blade 1 root;
    mbdy momentvec	blade2 2 2 blade2 # blade 2 root;
    mbdy momentvec	blade3 2 2 blade3 # blade 3 root;
    mbdy momentvec	blade1 13 1 local # blade 1 50% local e coo;
    mbdy momentvec	blade2 13 1 local # blade 2 50% local e coo;
    mbdy momentvec	blade3 13 1 local # blade 3 50% local e coo;	
; Displacements and accellerations
    mbdy state	pos tower 10 1 global only 1 # tower top fa displ;
    mbdy state	pos tower 10 1 global only 2 # tower top ss displ;
    mbdy state	acc tower 10 1 global only 1 # tower top fa acc;
    mbdy state	acc tower 10 1 global only 2 # tower top ss acc;	
;
    mbdy state	pos blade1 26 1 blade1 # blade 1 tip pos;
    mbdy state	pos blade2 26 1 blade2 # blade 2 tip pos;
    mbdy state	pos blade3 26 1 blade3 # blade 3 tip pos;
    mbdy state	pos blade1 26 1 global # gl blade 1 tip pos;	
; - Monitor Aerodynamics - ;
    aero windspeed	3 1 1 72.5;
    aero alfa	1 72.5;
    aero alfa	2 72.5;
    aero alfa	3 72.5;
    aero cl	1 72.5;
    aero cl	2 72.5;
    aero cl	3 72.5;
    aero cd	1 72.5;
    aero cd	2 72.5;
    aero cd	3 72.5;	
; - Main Controller -
; Output to controller
; dll outvec 1 1 # time;
; dll outvec 1 2 # slow speed shaft rad/s;
; dll outvec 1 3 # pitch angle 1;
; dll outvec 1 4 # pitch angle 2;
; dll outvec 1 5 # pitch angle 3;
; dll outvec 1 6 # WSP_x_global;
; dll outvec 1 7 # WSP_y_global;
; dll outvec 1 8 # WSP_z_global;
; dll outvec 1 9 # Elec. pwr ;
; dll outvec 1 10 # Grid flag ;
; Input from controller
    dll inpvec	1 1 # generator torque reference [nm];
    dll inpvec	1 2 # pitch angle reference of blade 1 [rad];
    dll inpvec	1 3 # pitch angle reference of blade 2 [rad];
    dll inpvec	1 4 # pitch angle reference of blade 3 [rad];
    dll inpvec	1 5 # power reference [w];
    dll inpvec	1 6 # filtered wind speed [m/s];
    dll inpvec	1 7 # filtered rotor speed [rad/s];
    dll inpvec	1 8 # filtered rotor speed error for torque [rad/s];
    dll inpvec	1 9 # bandpass filtered rotor speed [rad/s];
    dll inpvec	1 10 # proportional term of torque contr. [nm];
    dll inpvec	1 11 # integral term of torque controller [nm];
    dll inpvec	1 12 # minimum limit of torque [nm];
    dll inpvec	1 13 # maximum limit of torque [nm];
    dll inpvec	1 14 # torque limit switch based on pitch [-];
    dll inpvec	1 15 # filtered rotor speed error for pitch [rad/s];
    dll inpvec	1 16 # power error for pitch [w];
    dll inpvec	1 17 # proportional term of pitch controller [rad];
    dll inpvec	1 18 # integral term of pitch controller [rad];
    dll inpvec	1 19 # minimum limit of pitch [rad];
    dll inpvec	1 20 # maximum limit of pitch [rad];
    dll inpvec	1 21 # torque reference from dt dammper [nm];
    dll inpvec	1 22 # status signal [-];
    dll inpvec	1 23 # total added pitch rate [rad/s];
    dll inpvec	1 24 # filtered mean pitch for gain sch [rad];
    dll inpvec	1 25 # flag for mechnical brake [0=off/1=on];
    dll inpvec	1 26 # flag for emergency pitch stop [0=off/1=on];
    dll inpvec	1 27 # lp filtered acceleration level [m/s^2];	
; ; Output to generator model
; dll outvec 2 1  # time ;
; dll outvec 2 2  # Electrical torque reference [Nm] ;
; dll outvec 2 3  # omega LSS ;
; Input from generator model
    dll inpvec	2 1 # mgen lss [nm];
    dll inpvec	2 2 # pelec w;
    dll inpvec	2 3 # mframe;
    dll inpvec	2 4 # mgen hss;
    dll inpvec	2 5 # generator pmech kw;
    dll inpvec	2 6 # filtered gen speed;
    dll inpvec	2 7 # elec. pwr;
    dll inpvec	2 8 # grid flag;	
; Output to mechanical brake
    dll inpvec	3 1 # brake torque [nm];	
; ; Input from mechanical brake
; dll outvec 3 1 # Time [s] ;
; dll outvec 3 2 # Generator LSS speed [rad/s] ;
; dll outvec 3 3 # Deploy brake ;
; ; Output to pitch servo
; dll outvec 4 1 # time;
; dll outvec 4 2 # pitchref 1;
; dll outvec 4 3 # pitchref 2;
; dll outvec 4 4 # pitchref 3;
; dll outvec 4 5 # Emerg. stop;
; Input from pitch servo
    dll inpvec	4 1 # pitch 1;
    dll inpvec	4 2 # pitch 2;
    dll inpvec	4 3 # pitch 3;	
; Check tower clearence
    dll inpvec	5 1 # bltip tow min d [m];
  end output;	
;
  begin output_at_time aero 0.1;
    filename	res/at;
    twist 1;
    chord 1;
  end output_at_time;
  exit;
