MetalicaRap Build Speed Calculator

From RepRap
Revision as of 23:29, 12 December 2012 by Stormyzim (talk | contribs)
Jump to: navigation, search

You can use this build speed calculator to design your MetalicaRap. It's good for deciding: power supply size, beam power, deflection speed, build platform size, layer thickness, and digital to analogue converter speed for beam power modulation while considering factors like: How do these decisions vary between different manufacturing metals used? How do wall plug efficiency effects maintain supply requirements? How does beam to metal efficiency effect the process?


(More detailed help; highlighting the text between and including <html> and </html> below then copy (ctrlC) to clip board. ( if you're viewing this page in edit mode do not copy the pre and /pre statements at very beginning and end of code), Paste (ctrl+V) this into a blank document in notepad + + and then save this new file as "name.html". Open this name.html file by double clicking it or by opening it with your browser/firefox/explorer from the file open menu in the browser. Enjoy! (you can download Notepad++ here [1])

Online Design Tool: Build Speed Calculator for metals including Aluminum,Stainless,Tungsten,

Build speed Calculator Program shows you approximately how long it will take to build a part, based mainly on its external dimensions, metal type, metal fill percentage and power of the electron beam. You can enter these parameters and it will give you the build time.

To run this program you can copy the following code in the grey box below in to an text editor and then save as a name.html file, then open name.html in a browser and enter your values and press calculate build time button. ( for more detailed instructions see the bottom of this section)

<html>
<head>
<title>Build Speed Calculator </title>
<script>
//      N:B: This program takes Latent heat in to account only in build times, not in Frequency caculations!
//            This program's results are only rough guide as it simplifies the problem or does not consider the following options;
//            It considers the melt area under the beam as a cube with equal sided lenghts, the option to make the  X and Y directions longer will probably be implimented becasue;a) though the z layer thickness needs to be at final resolution specification as it can not possible to be varied across the build area, this is not true for the X & Y directions a variable spot size based approach would be advantagous b) the minimum feature size can be bigger than the print resolution. 
//
//
//            It Caculates diffusivity limit using Fourer's 2nd Law, 
//            Its durations do not include time for imaging or corection through vaporisation.
//           Mini research job for someone out their Some metal types diffusivity values have not been found, anyone can add them and remove commented out lines.
//   Program by Rapatan Tansen 5/2011   it will  be added to GIT once we sort it out so your versions can be added.
var stage;
var vaporized = 999999999;
var color = 'ffffff';
var ratio_required_for_cube_power_input_to_drop_below_vaporisation=0;
var ratio_power_input_drop_achievable_by_beam_scan_rate_doubling=0;
var multipass_build_slow_down_power_down_factor=0;
var ratio_needed_to_increase_maximum_hardware_scan_by_to_avoid_vaporisation=0;
var practicle_build_duration_message1='';
var practicle_build_duration_message2='';
var practicle_build_duration_message3='';
var scenario='';

function getValue(t) {  // function to go and fetch entry data variables by name from 'form' called 'calcform' ( see calcform at bottom of program)
   var i = document.getElementById('calcForm');
   var val = '0';

   for ( var j = 0; j < i.elements.length; j++ ) {
     if (i.elements[j].name == t) { // Finds name of variable in table of input variables
	val = i.elements[j].value;
     }
   }
   return( Number(val) );
}

function setValue(t, v) {  // function to go and put entry data variables by name from 'form' called 'calcform'
   var i = document.getElementById('calcForm');

   for ( var j = 0; j < i.elements.length; j++ ) {
     if (i.elements[j].name == t) { // Finds name of variable in table of input variables
		i.elements[j].value = v;
     }
   }
}

function makeOutput() {
  
    var depth = (getValue('depth')); // in metres
    var out = '<table border="1"><tr><th>Results</th></tr>';
    var beamspeed = depth / (meltTime(depth) + meltingTime(depth));
    var cubes = ( getValue('object_side_length_x')/100 * getValue('object_side_length_y')/100 * getValue('object_side_length_z')/100 ) / (depth*depth*depth); // x y z in cm convert to m , cubes in whole area fill not taken in to account here as preheat applied to whole area
    var fillfactor = getValue('fill') / 100;
    var passtime = cubes * ( 1 - fillfactor ) * depth / getValue('max_beam_speed');  // Time to pass cubes not melted
    var totalmelttime = cubes * ( meltTime(depth) + meltingTime(depth) ) * fillfactor;
	var finaltime = (totalmelttime + cubes*preheatTime(depth) + passtime) /60/60; // totalmelttime is taking in to accountthe fill factor, but preheat time is all build area (via cubes), passtime is kipped area
	 
	
	var totalvaptime = .001*cubes * ( meltTime(depth) + meltingTime(depth) + boilTime(depth) + boilingTime(depth) );  

	out += '<span style="color:grey;font-size:50%">build slow down factor;</span>'	+ (diffusionDeflectionHardwareLimitsOnBuildTime(depth)).toPrecision(3) + '  <span style="color:grey;font-size:50%">   Number of beam passes ; </span>' + (achievableCubePowerDropToAvoidVaporisationThroughBeamScanSpeedIncrease(depth) ).toPrecision(3) + '  <br/> '+'<br/>' ;
	out += 'Beam power leaving gun: ' + BeamPowerLeavingGun() + ' W <br/> '; 
	out += 'Build duration with metal diffusivity & deflection coil speed limit No defocus : melting time  ' + (((totalmelttime/60)/60)*diffusionDeflectionHardwareLimitsOnBuildTime(depth)).toPrecision(3) + ' hours  + preheating time  ' + ((cubes * preheatTime(depth)/60/60)*diffusionDeflectionHardwareLimitsOnBuildTime(depth)).toPrecision(3) + ' hours  + skipping time  ' + (passtime/60/60).toPrecision(2) + ' hours  =    ' + ((finaltime)*(diffusionDeflectionHardwareLimitsOnBuildTime(depth))).toPrecision(3) + ' hours to <span style="color:black;font-size:100%">build</span>        <br><br>'; 
	out += '             ' + practicle_build_duration_message1 + '   <br/>' + practicle_build_duration_message2 + '   '+ practicle_build_duration_message3 + '<br/>' ;
	
	
	
	var SpecialCasefinaltimeNodiffusionLimitOnPreheatAsDefocusBeam = (totalmelttime *(diffusionDeflectionHardwareLimitsOnBuildTime(depth))+ cubes*preheatTime(depth) + passtime) /60/60; //
	out += 'Build time with preheat defocused : melting time    ' + (((totalmelttime/60)/60)*diffusionDeflectionHardwareLimitsOnBuildTime(depth)).toPrecision(3) + ' hours  +  Defocused beam preheating time  ' + ((cubes * preheatTime(depth)/60/60)).toPrecision(3) + ' hours  + skip  ' + (passtime/60/60).toPrecision(2) + ' hours  = <u> <span style="color:black;font-size:160%"> ' + ((SpecialCasefinaltimeNodiffusionLimitOnPreheatAsDefocusBeam)).toPrecision(3) + ' hours to  build     </u> <br><br>'; 
	out += ' Build time ignoring metal diffusivity limit: melting time   ' + ((totalmelttime/60)/60).toPrecision(3) + ' hours  + preheating time  ' + (cubes * preheatTime(depth)/60/60).toPrecision(3) + ' hours  + skipping time  ' + (passtime/60/60).toPrecision(3) + ' hours  =  ' + (finaltime).toPrecision(3) + ' hours to build    <br>'; 
	out += 'Desired speed for <span style="color:black;font-size:140%">Digital to Analogue converter</span> controling beam power switching Off and On to achieve required melting : <u>'  + ((((1/( (meltTime(depth)) + (meltingTime(depth)) ))*(diffusionDeflectionHardwareLimitsOnBuildTime(depth))).toPrecision(8))/1000000) + ' MHz </u><br/><br/> ';
	
	
	out += 'Other info;<br/> ' ;
	
	
	out += ' Scenario : ' + scenario + '        .....    <br/>   ';	
	out += ' Total vaporisation time of 1000th of volume of part: ' + (totalvaptime/60/60).toPrecision(2) + ' hours <br/> '; 
	out += ' <span style="color:grey;font-size:50%">  Number of cubes within part: </span>' + (cubes).toPrecision(5) + '<br/> ';
	
	
	out += ' <span style="color:grey;font-size:50%">  Melt time 1 cube ( depth^3) </span> ' +  (meltTime(depth)).toPrecision(3) + ' <span style="color:grey;font-size:50%"> S   max thread exposure duration is  </span>' + (maxExposureDuration(depth)).toPrecision(2) + ' <span style="color:grey;font-size:50%">  S </span><br/> ';  // 
	out += ' <span style="color:grey;font-size:50%">  X Deflection coil scan sate ignoring diffusion limit: </span>' + (rasterXScanRate(depth)).toPrecision(5) + ' <span style="color:grey;font-size:50%">Hz .... X deflection coil scan rate taking in to acount diffusion limit </span> ' + (maxThreadExposureXScanRate(depth)).toPrecision(5) + '<span style="color:grey;font-size:50%">  Hz ....  </span> <br/>';
	out +=  '<span style="color:grey;font-size:50%"> Cube melt time no diffusion limit </span>' + (meltTime(depth)).toPrecision(4) + '<span style="color:grey;font-size:50%"> S    Cube melt time with diffusion limit </span> ' + (maxExposureDuration(depth)).toPrecision(4) +'<span style="color:grey;font-size:50%">  S .... </span> <br/>';
	
	out += '  <span style="color:grey;font-size:50%"> beam speed :</span> ' + (beamspeed).toPrecision(5) + '<span style="color:grey;font-size:50%">  m/s          .....    </span>   ';
	
   
	out += '  <span style="color:grey;font-size:50%"> Time spent on moving beam across non-treated areas: </span>' + (passtime/60/60).toPrecision(2) + ' <span style="color:grey;font-size:50%"> hours </span><br/> '; 
    
   
   out += '<span style="color:grey;font-size:50%"> Checks; </span><br/> ' ;
   out += ' <span style="color:grey;font-size:50%">      solid phase: </span>' + meltTime( depth ) * 1000;
   out += '  <span style="color:grey;font-size:50%">  μs        melting phase:  </span> ' + meltingTime( depth ) * 1000;
   out += ' <span style="color:grey;font-size:50%">   μs        liquid phase:  </span> ' + boilTime( depth ) * 1000;
   out += ' <span style="color:grey;font-size:50%">   μs        boiling phase:   </span>' + boilingTime( depth ) * 1000;
   out += ' <span style="color:grey;font-size:50%">   μs      </span> ';    
   out += ' <span style="color:grey;font-size:50%">   δT     <sub>solid</sub>  </span>' + solidTemp( meltTime(depth), depth ) + '   ' ; 
   out += ' <span style="color:grey;font-size:50%">  T           <sub>melting</sub>      </span>  ' + ( solidTemp( meltTime(depth), depth ) + getValue('preheat') ) + '  <br> ' ; 
   out += ' <span style="color:grey;font-size:50%">  practicle_build_speed_factor_output via scnario sub routine with max raster rate check </span>' + (diffusionDeflectionHardwareLimitsOnBuildTime(depth)).toPrecision(3)  + ' <br> <span style="color:grey;font-size:50%"> The upped multipass scan rate is this amout larger than the entered scanrate limit ( limited by hardware )     </span>  ' + (practicalDurationMultiplicationFactor(depth)).toPrecision(3) +'   <br>'; 
   out += ' <span style="color:grey;font-size:50%">  multipass_build_slow_down_power_down_factor (when none = 1) </span>' + (diffusionDeflectionHardwareLimitsOnBuildTime(depth)).toPrecision(3)  +'   <br>'; 
   out += ' <span style="color:grey;font-size:50%">  cube Power Reduction Required To Avoid Vaporiseation (when none = 1) </span>' + (cubePowerReductionRequiredToAvoidVaporiseation(depth)).toPrecision(3)  +'   <br>'; 
   out += ' <span style="color:grey;font-size:50%">  achievable Cube Power Drop To Avoid Vaporisation Through Beam Scan Speed Increase </span>' + (achievableCubePowerDropToAvoidVaporisationThroughBeamScanSpeedIncrease(depth)).toPrecision(3)  +'   <br>'; 
   out += '<br/>' ; 
   
   
   out += '<table border="1"><tr><th>Time</th><th>Temperature of unit cube</th><th>Stage</th></tr>';
   for ( i = 1 ; i <= getValue('steps'); i++ ) {
      var t = i * getValue('timestep');

      var res = calcTemp(t, depth);
      

      out = out + '<tr><td>' + t + '</td><td bgcolor="#' + color + '">' + res + '</td><td>'+ stage +'</td></tr>';
   }

   out = out + '</table>';
   return(out);
}


function mass(depth) {
   return(getValue('density_solid') * depth * depth * depth ); // get mass of box KG ,cubing lenght each lenght from cm to m to get volume x density giving mass kg
}

function WallSocketPower() {
   return power = getValue('current_beam') * getValue('voltage_gun')*(1/(getValue('wallplugefficiency')/100));    
}

function BeamPowerLeavingGun() {
   return power = (getValue('current_beam') * getValue('voltage_gun'));    
}

function beamPower() {
   return power = (getValue('current_beam') * getValue('voltage_gun')*(getValue('BeamToMetalAbsorbtionEfficiency')/100));    
}


function preheatTime(depth) {
   var d_T =  getValue('preheat') - getValue('InitialRoomTempinK'); //   all Kelvin  To det the duration up to preheat temp first remove the starting temprature ie room temp 18C 291 from preheat temp
   return(d_T * mass(depth) * getValue('shc_solid') / beamPower() );  // mass KG beam W  required change in temprature times specific heat solid divided by supplied beam power
}

function meltTime(depth) {
   var d_T = getValue('melting_point') - getValue('preheat');
   return(d_T * mass(depth) * getValue('shc_solid') / beamPower() );
}

function meltingTime (depth) {
   return( mass(depth) * getValue('heat_of_fusion_melt') / beamPower() );
}

function boilTime (depth) {
   var d_T = getValue('boiling_point') - getValue('melting-point');
   return(d_T * mass(depth) * getValue('shc_liquid') / beamPower() );
}

function boilingTime (depth) {
   return( mass(depth) * getValue('heat_of_fusion_boil') / beamPower() ); //  checks on temp transition values
}

function vaporizeTime (depth) {
	return (99999);
}

function solidTemp (time, depth) {
   var d_T = time * beamPower() / ( mass(depth) * getValue('shc_solid') ); //  checks on temp transition values

   return ( getValue('preheat') + d_T );

}

function liquidTemp (time, depth) {
   var d_T = time * beamPower() / (mass(depth) * getValue('shc_liquid') );

   return ( getValue('melting_point') + d_T );
}
function thermalDiffusivity() {
	var a= ((getValue('thermal_conductivity')) / (getValue('density_solid')*getValue('shc_solid')));
	return (a); // ok
}

function maxExposureDuration(depth){ //all the following routines caculate limits imposed from vaporisation avoidance and hardware scan rate limits.
	var time=((Math.PI)/(thermalDiffusivity()))*(((getValue('melting_point')*getValue('thermal_conductivity'))/(2*((beamPower())/(depth*depth)))) *((getValue('melting_point')*getValue('thermal_conductivity'))/((beamPower())/(depth*depth))));
	//   Time to vaporise is solution of Fourier 2nd law; which says 
    //	second difeerential (ie accleeration of change) of Temperature T with depth z is equal to one over the thermal difussivity times fist differential of temperature T against Time t
    // under steady state conditions with different tempratures at ends of a virtual section or rod or cooling path, temperature across a long cyclinder/rod/cooling path  	at any point is constant as emergy flows through bar
    //  So temperature only changes when  the rate of heat flow changes (SECOND DIFFERENTIAL ) that thus produce chages in bar 
    // solved for initial state z= 0  surface of bar and z= infintie where no change of temprature 
    //and in case where t= 0 then current temprature is equal to initial tmeprature
    // So you get above formula ; formula(5.3) see p256 - p258  in William M steen Laser material processing (version 4) chapter 5.3 
    // analytical models of one dimensional heat flow   Ie one dimension is beam spot on metal; which flows in x y and z directions are analyzed,  
	return(time); 	
}	
	
function rasterXScanRate(depth) { // this routine calculates scanrate (Hz) based on time taken to process x axis lenght of cubes * 2 ignoring latent heat fusion
	var melt_cubes_across_X_lenght_in_part = (((getValue('object_side_length_x')/100)/(getValue('depth'))))
	
	//this rate and the following subroutines are beimg compared with rate from Fourier 2nd law that does not take in to account latent heat of fusion 
	// So we have to ignore latent heat of fusion as that only applies whereupon the melt temprature has been reached 
	// but we are using this for the scan rate for all preheating and heating up to melt temprature, 
	var period = 2*(melt_cubes_across_X_lenght_in_part*((meltTime(depth)))); // shouold this be maxExposureDuration(depth)
	return ( 1/(period)); 
}

function maxThreadExposureXScanRate(depth) { // this routine caclulates the upped scan rate (Hz) caused my the need for multipasses of beam.
   var multi_pass_period = (((maxExposureDuration(depth)))*((getValue('object_side_length_x')/100)/(getValue('depth')))); 
   // 
   // .toFixed() ROUND UP DOES NOT WORK CHECK WITH PROGRAMMERis a round up form of command  cubemelttime/max exposure duration for thread 
   return ((1/(multi_pass_period)));
}
function cubePowerReductionRequiredToAvoidVaporiseation(depth) { // this routine caclulates the required cube power down ratios to avoid vaporisation.
   var ratio_required_for_cube_power_input_to_drop_below_vaporisation= (((meltTime(depth)))/(maxExposureDuration(depth))); 
   // 
   // 
   return (ratio_required_for_cube_power_input_to_drop_below_vaporisation);
}

function achievableCubePowerDropToAvoidVaporisationThroughBeamScanSpeedIncrease(depth) { 
    // this routine caclulates the required cube power down ratios to avoid vaporisation.
var   ratio_power_input_drop_achievable_by_beam_scan_rate_doubling = ((getValue('max_hardware_limited_raster_scanrate'))/(maxThreadExposureXScanRate(depth))); 
   // each bite at the cherry with no vaporisation is done at freq.of maxThreadExposureXScan Rate(depth) Hz how many of these can fit in Max hardware limit scan rate
   // If say 8 bites at the cherry are required to transfer enouch heat to cube,
   // than a 8x maxThreadExposureXScan Rate(depth)Hz value of Max hardware scanrate would mean that no consequential delay.
   // this case only works for max hardware scan rate being bigger than depower factor times rasterXscanrate 
   //(meltTIme/max exposure) 
   // If max hardware scan rate is smaller ie returned ratio_power_input_drop_achievable_by_beam_scan_rate_doubling < 1
   // then must apply (1<) cube reduction required to duration in main subroutine.
   if ( ratio_power_input_drop_achievable_by_beam_scan_rate_doubling < 1 ) {
   // It can be low for two reasons, 
   //1)  if max hardware is low / nearly 0  it will still just times build by factor required    
   //2)   and max threadexposure scan is high ( which is commmen )  
   // when max hardware is low we want it to increase duration and this fraction of 1 shows how far too low 
   // need to hand back how far too low.. Also still need to test for the remaining factor to times build speed 
   // by setting ratio_power_input_drop_achievable_by_beam_scan_rate_doubling=1  but not here do in main subroutine.
    // no doubling of beam speed possible so reduction must be achieved through build duration lengthening.          
    } else {
    // doubling of beam speed possible use above calculated value rounded up DO rounding later LATER &&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&& 
	// result should be 2 or higher  what happens when not all needed need another check? 
	// So caclulate required factor then
    //	IF achievable factor is higher set achivable equal to required. 
var	ratio_power_input_drop_achievable_by_beam_scan_rate_doubling=(ratio_power_input_drop_achievable_by_beam_scan_rate_doubling).toPrecision(2)
	   if ( (cubePowerReductionRequiredToAvoidVaporiseation(depth)) < ratio_power_input_drop_achievable_by_beam_scan_rate_doubling ) {
     //  all the required power drop can be achieved through increased beam speed / increased raster speed.
var  ratio_power_input_drop_achievable_by_beam_scan_rate_doubling=(cubePowerReductionRequiredToAvoidVaporiseation(depth)) ;
      
                
        } else {
    // the increased beam speed cannot account for all required reduction, 
	//ie need to lenghten build duration by the outstanding amount & drop or pulse power
	
        }
   }
   return (ratio_power_input_drop_achievable_by_beam_scan_rate_doubling);
}



function practicalDurationMultiplicationFactor(depth) { // this calculates how many times higher the upped scan rate is compared to the max hardware limited scan rate
   var factor = (maxThreadExposureXScanRate(depth))/(getValue('max_hardware_limited_raster_scanrate')); // .toFixed() needs to be rounded up TOP not bottom put back in later? 
   return ( factor );
}

function diffusionDeflectionHardwareLimitsOnBuildTime(depth) { // these calculations ignore the latent heat effects as vaporisation time Fourier 2nd law ignores it too.
   
   if ( (meltTime( depth )) < (maxExposureDuration(depth))) {
      // No Need to take a second pass  or extend build time with pulseWidthModulatebeampowerdrop, var practicle_hardware_build_speed_factor=1; practicle_build_duration_message1=''; practicle_build_duration_message2='';
     var  multipass_build_slow_down_power_down_factor=1;   
		  practicle_build_duration_message1= ' Multi passes not required';
	      practicle_build_duration_message2=' Current delfection scan rate hardware limit is '+ ((getValue('max_hardware_limited_raster_scanrate')).toPrecision(7)) + ' Hz   '; // kug
  	      practicle_build_duration_message3='  Required deflection coil scan rate hardware limit (Hz) would need to be ' + ((rasterXScanRate(depth)).toPrecision(7)); // how can I add so outputs desired_scan_rate_possible_new_redesign design= practicalDurationMultiplicationFactor(depth)*rasterXScanRate(depth)

           scenario=' A   Coil drivers can achieve required speed & metal diffusion limit not reached, so no multipass required ( design could be pushed harder?)';
   } else {
            // If cube melt time is above max exposuire duration; So Need to take a second pass or extend build duration at reduced power, so as not overload metal diffusion rate 
            // or will multi pass demand too higher speed of deflection coil; So need to increase build duration and drop power.
			
			// Reduction by ratios "ratio_required_for_cube_power_input_to_drop_below_vaporisation" (rounded up) "ratio_power_input_drop_achievable_by_beam_scan_rate_doubling" 
		    // remaining requirement achieved through extending build duration & power drop Pulse Width Modulated beam power drop
	   	    // =  (needs1<)ratio_required_for_cube_power_input_to_drop_below_vaporisation/(or limited to required amount) ratio_power_input_drop_achievable_by_beam_scan_rate_doubling = multipass_build_slow_down_power_down_factor
	    	
             // calculate remaining cube power drop thats required after increasing the beam speed up as much as posible ( or as much as needed so result is 1 for multipass_build_slow_down_power_down_factor)	      
           if ( achievableCubePowerDropToAvoidVaporisationThroughBeamScanSpeedIncrease(depth) > 1 ) {
		   
	    var   multipass_build_slow_down_power_down_factor=((cubePowerReductionRequiredToAvoidVaporiseation(depth))/(achievableCubePowerDropToAvoidVaporisationThroughBeamScanSpeedIncrease(depth))); 
              
			   if ( multipass_build_slow_down_power_down_factor < 2 ) {
	              // No build & power slow down is required, all achieved through beam speed up
                       practicle_build_duration_message1= ' Multi passes required , deflection coil hardware can cope with beam moving faster, ';
               var     multipass_build_slow_down_power_down_factor =1;  
	                   practicle_build_duration_message2=' Delfection scan rate is '+ (((maxThreadExposureXScanRate(depth))*(achievableCubePowerDropToAvoidVaporisationThroughBeamScanSpeedIncrease(depth))).toPrecision(7)) + ' Hz   '; // + maxThreadExposureXScanRate(depth)     add later
                       practicle_build_duration_message3='';
				   scenario=' B     BeamSpeed/Scanrate rate increased coil drivers can cope with increase';
				   
       		    } else {

                  // multipass_build_slow_down_power_down_factor >= 2 So need both deflection coil increase and build time lenghtening with power drop
                     practicle_build_duration_message1='  To avoid lenghtened build duration (above), caused by deflection coil hardware being too slow, increase maximum hardware deflection coil speed by improving coil drvier circuits (more expensive drivers running coils at incresed volatges and currents ) ';
					 practicle_build_duration_message2='  Current delfection scan rate is '+ (((maxThreadExposureXScanRate(depth))*(achievableCubePowerDropToAvoidVaporisationThroughBeamScanSpeedIncrease(depth))).toPrecision(7)) + ' Hz   '; // + maxThreadExposureXScanRate(depth)     add later
					 practicle_build_duration_message3='  To avoid build time lenghtineing required deflection coil scan rate (Hz) would need to be ' + ((practicalDurationMultiplicationFactor(depth)*rasterXScanRate(depth)).toPrecision(7)); // how can I add so outputs desired_scan_rate_possible_new_redesign design= practicalDurationMultiplicationFactor(depth)*rasterXScanRate(depth)
                  scenario=' C   BeamSpeed/Scanrate rate increase & Increase build duration  Coils cannot go fast enough use pulsed power';
				}
		   } else {
		   // find how far too low max hardware scan rate is; 1/ratio_power_input_drop_achievable_by_beam_scan_rate_doubling  give as duration lengthening factor & multiply with maxThreadExposureXScanRate(depth) the freq based on maxdurationTIme on cube
		     
 		var  multipass_build_slow_down_power_down_factor= (1/(achievableCubePowerDropToAvoidVaporisationThroughBeamScanSpeedIncrease(depth)));
		   
	        
	                 practicle_build_duration_message1='  Coils operate so slow that they cannot even meet a multipass scan rate,  increase maximum hardware deflection coil speed by improving coil drvier circuits  (more expensive drivers running coils at incresed volatges and currents ) ';    
	   				 practicle_build_duration_message2=' Current delfection scan rate hardware limit is '+ ((getValue('max_hardware_limited_raster_scanrate')).toPrecision(7)) + ' Hz   '; // kug
					 practicle_build_duration_message3='  Scan rate required to achive even multipass scanrate deflection coil scan rate, hardware limit (Hz) would need to be ' + ((multipass_build_slow_down_power_down_factor*(getValue('max_hardware_limited_raster_scanrate'))).toPrecision(7))+'  Hz     To achive no extension in  build duration a single pass scan rate, deflection coil scan rate hardware limit (Hz) would need to be ' + ((multipass_build_slow_down_power_down_factor*(getValue('max_hardware_limited_raster_scanrate'))*cubePowerReductionRequiredToAvoidVaporiseation(depth)).toPrecision(7)); // 
                  scenario=' D    Increase build duration, Coils cannot go fast enough use pulsed power';
				}
		   
		   // let it equal 1 to caculate remainder 
		   //NOT NEED? ratio_power_input_drop_achievable_by_beam_scan_rate_doubling = 1;
		    // multipass_build_slow_down_power_down_factor=(cubePowerReductionRequiredToAvoidVaporiseation(depth))/ (achievableCubePowerDropToAvoidVaporisationThroughBeamScanSpeedIncrease(depth)); 
           }
       return (multipass_build_slow_down_power_down_factor);
}
   
function calcTemp(time, depth) {
   var res = 0;
   var time_solid = meltTime( depth );
   
   if ( time < time_solid ) {
      stage = 'solid A'
	  color = 'ffffff'
      // Solid
      res = solidTemp(time, depth);            
   } else {
      
      time = time - time_solid;
      var time_melting = meltingTime( depth )

      if (time <= time_melting) {
          // Melting
      stage = 'solid B'
	  color = 'ffffff'
          res = getValue('melting_point');
      } else {
          
          time = time - time_melting;
          var time_liquid = boilTime( depth );
          if ( time < time_liquid ) {
		stage = 'Melting C'
	  color = '0000ff'
             // Liquid
             res = liquidTemp(time, depth);
          } else {

             time = time - time_liquid;
           
             var time_boiling = boilingTime( depth );
             
             if (time <= time_boiling ) {
             stage = 'Liquid D'
	  color = '0000ff'
	        // Boiling
           	res = getValue('boiling_point');

			} else {
				time = time - time_boiling;
				var time_vapor = vaporizeTime( depth );
				if (time <= time_vapor) {
				
					stage = 'Vapor E'
	  color = 'ff0000'
			// Vaporised
                res = 'gone';  
				} else {
					alert('error');
				}

             }
          }
       }
   }                

   return(res);

}

function selectmetal(s) { // s = metal choise field    STILL TO GET FIGURES FOR Cobalt chromium , copper  , gold and molybdenium, 006 before decimal means not got number yet
	if(s == "titanium")
	{
		setValue('preheat', 1648);//  K                       complete data
		setValue('BeamToMetalAbsorbtionEfficiency', 85);//  %
		setValue('density_solid', 4510);//  kg/m^3  
		setValue('melting_point',1668);//  K   T
		setValue('boiling_point', 3260);//  K   T
		setValue('shc_solid', 519);//  J/kg/K  
		setValue('shc_liquid', 519);//  J/kg/K 
		setValue('heat_of_fusion_melt',437000);//  J/kg 
		setValue('heat_of_fusion_boil', 9000000);//  J/kg 
		setValue('thermal_conductivity',19);//  W/m/K      K
		setValue('thermal_diffusivity', 0.0000081);// m^2/s   check factor of 10 out?
		
	}else if(s == "aluminium")
	{
		setValue('preheat', 640);//  K                          complete data
		setValue('BeamToMetalAbsorbtionEfficiency', 0085);//  %
		setValue('density_solid', 2700);//  kg/m^3
		setValue('melting_point',660);//  K
		setValue('boiling_point', 2450);//  K
		setValue('shc_solid', 900);//  J/kg/K 
		setValue('shc_liquid', 900);//  J/kg/K   check
		setValue('heat_of_fusion_melt',397000);//  J/kg 
		setValue('heat_of_fusion_boil', 9492000);//  J/kg 
		setValue('thermal_conductivity',226);//  W/m/K
		setValue('thermal_diffusivity', 0.000093);// m^2/s
	}else if(s == "cobalt_chromium")
	{
		setValue('preheat', 001667);//  K
		setValue('BeamToMetalAbsorbtionEfficiency', 0085);//  %
		setValue('density_solid', 004350);//  kg/m^3
		setValue('melting_point',1491);//  K
		setValue('boiling_point', 003260);//  K
		setValue('shc_solid', 00622);//  J/kg/K 
		setValue('shc_liquid', 00622);//  J/kg/K 
		setValue('heat_of_fusion_melt',00440000);//  J/kg 
		setValue('heat_of_fusion_boil', 009830000);//  J/kg 
		setValue('thermal_conductivity',226);//  W/m/K
		setValue('thermal_diffusivity', 0.000095);// m^2/s
	}else if(s == "copper")
	{
		setValue('preheat', 1063);//  K   copper type; C10100 name; oxygen free elctronic coppper, 
		setValue('BeamToMetalAbsorbtionEfficiency', 0085);//  %aplication  for bus tube, conductors, vacuum seals , 
		setValue('density_solid', 8900);//  kg/m^3  glass to metal seals wave guides (Use C65100 for heat exchange electrical conduits)
		setValue('melting_point',1083);//  K
		setValue('boiling_point', 002260);//  K   
		setValue('shc_solid', 385);//  J/kg/K 
		setValue('shc_liquid', 385);//  J/kg/K 
		setValue('heat_of_fusion_melt',00440000);//  J/kg 
		setValue('heat_of_fusion_boil', 009830000);//  J/kg 
		setValue('thermal_conductivity',391);//  W/m/K
		setValue('thermal_diffusivity', 0.000095);// m^2/s ok Source: wikipedia
	}else if(s == "gold")
	{
		setValue('preheat', 1295);//  K
		setValue('BeamToMetalAbsorbtionEfficiency',85);//  %
		setValue('density_solid', 19300);//  kg/m^3 19.32Mg/m^3
		setValue('melting_point',1335);//  K
		setValue('boiling_point', 002260);//  K
		setValue('shc_solid', 131);//  J/kg/K 
		setValue('shc_liquid', 00622);//  J/kg/K 
		setValue('heat_of_fusion_melt',00440000);//  J/kg 
		setValue('heat_of_fusion_boil', 009830000);//  J/kg 
		setValue('thermal_conductivity',300);//  W/m/K
		setValue('thermal_diffusivity', 0.000095);// m^2/s
	}else if(s == "iron")
	{
		setValue('preheat', 1516);//  K                        complete data
		setValue('BeamToMetalAbsorbtionEfficiency', 85);//  %
		setValue('density_solid', 7870);//  kg/m^3
		setValue('melting_point',1536);//  K
		setValue('boiling_point', 3000);//  K
		setValue('shc_solid', 460);//  J/kg/K 
		setValue('shc_liquid', 00460);//  J/kg/K 
		setValue('heat_of_fusion_melt', 275000);//  J/kg 
		setValue('heat_of_fusion_boil', 6362000);//  J/kg 
		setValue('thermal_conductivity',50);//  W/m/K
		setValue('thermal_diffusivity', 0.0000138);// m^2/s  ok Source: wikipedia
	}else if(s == "molybdenium")
	{
		setValue('preheat', 001667);//  K
		setValue('BeamToMetalAbsorbtionEfficiency', 0085);//  %
		setValue('density_solid', 004350);//  kg/m^3
		setValue('melting_point',1491);//  K
		setValue('boiling_point', 003260);//  K
		setValue('shc_solid', 00622);//  J/kg/K 
		setValue('shc_liquid', 00622);//  J/kg/K 
		setValue('heat_of_fusion_melt',00440000);//  J/kg 
		setValue('heat_of_fusion_boil', 009830000);//  J/kg 
		setValue('thermal_conductivity',226);//  W/m/K
		setValue('thermal_diffusivity', 0.000095);// m^2/s
	}else if(s == "stainlesssteel")
	{
		setValue('preheat', 1430);//  K    stainless steel 304   complete data
		setValue('BeamToMetalAbsorbtionEfficiency', 85);//  %
		setValue('density_solid', 8030);//  kg/m^3
		setValue('melting_point',1450);//  K
		setValue('boiling_point', 3000);//  K
		setValue('shc_solid',500);//  J/kg/K 
		setValue('shc_liquid',500);//  J/kg/K check
		setValue('heat_of_fusion_melt',300000);//  J/kg 
		setValue('heat_of_fusion_boil', 6500000);//  J/kg 
		setValue('thermal_conductivity', 21.4);//  W/m/K
		setValue('thermal_diffusivity', 0.000005);// m^2/s ok tainless 304
	}else if(s == "tungsten")
	{
		setValue('preheat', 3390);//  K                             complete data
		setValue('BeamToMetalAbsorbtionEfficiency', 85);//  %
		setValue('density_solid', 19300);//  kg/m^3
		setValue('melting_point',3410);//  K
		setValue('boiling_point', 5930);//  K
		setValue('shc_solid', 140);//  J/kg/K 
		setValue('shc_liquid', 140);//  J/kg/K  check
		setValue('heat_of_fusion_melt',185000);//  J/kg 
		setValue('heat_of_fusion_boil', 4020000);//  J/kg 
		setValue('thermal_conductivity',164);//  W/m/K    K
		setValue('thermal_diffusivity', 0.0000607);// m^2/s
	}else if(s == "prg_test_1kg_1k_titanium")
	{
	    setValue('object_side_length_x', 6.12);// this defines 6.12 cude which weighs 1Kg 
	    setValue('object_side_length_y', 6.12);//
	    setValue('object_side_length_z', 6.12);//
	    setValue('depth', 0.0612);//  this is the whole 1Kg cube in one go
		setValue('preheat', 1667);//    This is for testing this program is reasnable acurate. ADD X Y Z DEPTH 
		setValue('current_beam', 1);//   So ignore frequency calculation results as treating 1kg titanium block as one cube 
		setValue('voltage_gun', 731.77);//this is set to specific heat capacity unity settings ie 622Watt at 1Kg Titanium at 1K
		setValue('BeamToMetalAbsorbtionEfficiency', 85);//  %
		setValue('density_solid', 4510);//  kg/m^3  
		setValue('melting_point',1668);//  K   T
		setValue('boiling_point', 3260);//  K   T
		setValue('shc_solid', 519);//  J/kg/K  
		setValue('shc_liquid', 519);//  J/kg/K 
		setValue('heat_of_fusion_melt',437000);//  J/kg 
		setValue('heat_of_fusion_boil', 9000000);//  J/kg 
		setValue('thermal_conductivity',19);//  W/m/K      K
		setValue('thermal_diffusivity', 0.0000081);// m^2/s   check factor of 10 out?
		setValue('timestep', 0.5);// s  
		setValue('steps', 40);//  	
	}
}

</script>
</head>
<body>

<form id="calcForm">
<h1>Build Speed Calculator <select name="metal_selector" onChange="selectmetal(this.value);" style="font-size: 90%;"> <!-- "this" is just the selectbox alert('titanium'); -->
	<option value="aluminium">Aluminium</option>
	<!--                       <option value="cobalt_chromium">Cobalt Chromium</option>  ENTER FIGURES ABOVE    then remove comment arrows -->
    <!--                       <option value="copper">Copper</option>                    ENTER FIGURES ABOVE    then remove comment arrows -->
    <!--	                   <option value="gold">Gold</option>                        ENTER FIGURES ABOVE    then remove comment arrows -->
	<option value="iron">Iron</option>
    <!--	                   <option value="molybdenium">Molybdenium</option>          ENTER FIGURES ABOVE    then remove comment arrows -->
	<option value="stainlesssteel">StainlessSteel</option>
	<option value="titanium" selected="selected">Titanium</option>
	<option value="tungsten">Tungsten</option>
	<option value="prg_test_1kg_1k_titanium">Prg Test 1Kg 1K Titan.</option>
</select> How much money should you spend on; Power Supply?  Deflection coil drive circuits?  Digital to Analogue converter? </h1>



Final printed object size: x <input type="text" size="6" name="object_side_length_x" value="30" style="border: solid 1px #FF9900; font-size:110%;"/> y <input type="text" size="6" name="object_side_length_y" value="30" style="border: solid 1px #FF9900; font-size:110%;"/> z <input type="text" size="6" name="object_side_length_z" value="2" style="border: solid 1px #FF9900; font-size:110%;" /> cm    
Layer <span style="color:black;font-size:140%">depth</span> defining final print resolution: <input type="text" size="6" name="depth" value="0.000023" style="border: solid 1px #FF9900; font-size:110%;"/> m      
Fill: <input type="text" size="2" name="fill" value="20" />% <br/><br/>


Initial Room Temprature in Kelvin: <input type="text" size="4" name="InitialRoomTempinK" value="291"  /> K  
          
Metal preheat temperature ( normally 20C below melt tempreature ): <input type="text" size="4" name="preheat" value="1648" style="border: solid 1px #FF9900; font-size:110%;"/> K <br/>

Wall plug efficiency: <input type="text" size="3" name="wallplugefficiency" value="85" /> %  
                       
                      
Beam to metal absorbtion efficiency: <input type="text" size="3" name="BeamToMetalAbsorbtionEfficiency" value="85" /> % <br/><br/>

Wall socket <span style="color:black;font-size:140%">power:</span>: <input type="text" size="2" id="RequiredWallSocketPower" value="" /> W 
      
Gun voltage: <input type="text" size="4" name="voltage_gun" value="100000"style="border: solid 1px #FF9900; font-size:110%;" /> V  
  
Beam current: <input type="text" size="2" name="current_beam" value="0.010" style="border: solid 1px #FF9900; font-size:110%;"/> A  
 
Beam power entering metal: <input type="text" size="4" id="powercell" value="" /> W 
      <br/><br/>

Maximum hardware speed to drive Scan Rate for <span style="color:black;font-size:140%">deflection coils :</span> <input type="text" size="6" name="max_hardware_limited_raster_scanrate" value="160000" style="border: solid 1px #FF9900; font-size:110%;"/> Hz ( typical 24000)   &nbsp  <br/>
Maximum beam speed used when skipping nonpart areas: <input type="text" size="6" name="max_beam_speed" value="8000" style="border:  font-size:110%;" /> m/s   &nbsp <br/>


<span style="color:grey;font-size:50%">Constants; Solid density: </span><input type="text" size="6" name="density_solid" value="4350" style="font-size:50%;color:grey"/> <span style="color:grey;font-size:50%">kg/m<sup>3</sup></span>    <!--change 'text' to hidden to hide text on simple version -->
<span style="color:grey;font-size:50%">Melting point: </span><input type="text" size="6" name="melting_point" value="1668" style="font-size:50%;color:grey"/><span style="color:grey;font-size:50%"> K </span>   <!--  -->
<span style="color:grey;font-size:50%">Boiling point: </span><input type="text" size="6" name="boiling_point" value="3260" style="font-size:50%;color:grey"/><span style="color:grey;font-size:50%"> K</span>    <!--  -->
<span style="color:grey;font-size:50%">Solid specific heat capacity:</span> <input type="text" size="6" name="shc_solid" value="622" style="font-size:50%;color:grey"/> <span style="color:grey;font-size:50%">J/kg/K </span><br/><!--  -->
<span style="color:grey;font-size:50%">Liquid specific heat capacity:</span> <input type="text" size="6" name="shc_liquid" value="622" style="font-size:50%;color:grey"/><span style="color:grey;font-size:50%"> J/kg/K</span>    <!--  -->
<span style="color:grey;font-size:50%">Latent heat of fusion/melting:</span> <input type="text" size="6" name="heat_of_fusion_melt" value="440000" style="font-size:50%;color:grey"/> <span style="color:grey;font-size:50%">J/kg </span>   <!-- style="font-size:50%;color:grey" -->
<span style="color:grey;font-size:50%">Latent heat of Fusion/boiling: </span><input type="text" size="6" name="heat_of_fusion_boil" value="9830000" style="font-size:50%;color:grey"/> <span style="color:grey;font-size:50%">J/kg </span><br/><!-- style="font-size:50%;color:grey" -->
<span style="color:grey;font-size:50%">Thermal Conductivity : </span><input type="text" size="6" name="thermal_conductivity" value="226" style="font-size:50%;color:grey"/><span style="color:grey;font-size:50%"> W/m/K </span>   <!-- style="font-size:50%;color:grey" -->
<span style="color:grey;font-size:50%">Thermal Diffusivity: </span><input type="text" size="6" name="thermal_diffusivity" value="0.000095" style="font-size:50%;color:grey"/><span style="color:grey;font-size:50%"> m<sup>2</sup>/s </span>   <!-- <span style="color:grey;font-size:50%"> to get rid of text -->
<span style="color:grey;font-size:50%">Table output Format definition, Time step:</span> <input type="text" size="6" name="timestep" value="0.00000005" style="font-size:50%;color:grey" ;/> <span style="color:grey;font-size:50%">s</span>  <!--  -->
  
<span style="color:grey;font-size:50%">number of Steps:</span> <input type="text" size="6" name="steps" value="40" style="font-size:50%;color:grey"/> <br/>
<input type="submit" value="Calculate build duration" onClick="document.getElementById('output').innerHTML = makeOutput(); document.getElementById('powercell').value = beamPower(); return(false)" /><!-- document is way to refer whole page java comand getelementbyid .value refers to its value which is set to beampower, return false stops normal referesh of whole page-->
<input type="submit" value="Calculate required wall socket power" onClick="document.getElementById('outputWallP').innerHTML = makeOutput(); document.getElementById('RequiredWallSocketPower').value = WallSocketPower(); return(false)" />

</form>

<p id="output">

</p>
<p id="outputWallP">

</p>
</body>
</html>