#!/bin/awk -f BEGIN{ a=320; b=2.5; c=4.54 n[0]=c-1; p=3984.45092096; srand(); deadcount=bound(1,ARGV[2],ARGV[3]); power=bound(0,3500,ARGV[1]); assemblies=bound(32,256,ARGV[2]); trials=1; trial=0; max_generation=0 neutron_count[1]=0; neutron_history[1]=0; if(power == 0) { print "Power can not be zero!"; exit; }; for(x=1;x<=a;x++) { n[x]=s=(1.5*(x/a)^(-3/2))*b^(-0.08/(x/a)^2)+c-(2*exp(-x/(1.8745*a))-1)^-1; }; while(trial "lifetime"; max_generation=max_generation+temp; trial++; }; print "Average lifetime: "max_generation/trials; for(nh=1;nh<=length(neutron_history);nh++) { printf "%s\t%s\n",nh,neutron_count[nh]/neutron_history[nh] > "neutron_profile"; }; } function decay(a,p,assemblies,deadcount,power) { dead=0; generation=0; count=0; dcount=0; for(r=1;r<=assemblies;r++) { reactor[r]=0";"n[0]; }; while(1) { partial=0; while(dead= dcount) { dcount=0; #print "Count: "count" Power setting: "power" Maximum power: "maximum_power" neutron_potential :"neutron_potential" Actual power: "actual_power" Decay rate: "decay_rate partial=int(0.1*(length(reactor)-dead)); check_partial=0; while(drate a) { if(c >= b) return b; if(c <= a) return a; return c; } if(a > b) { if(c >= a) return a; if(c <= b) return b; return c; } if (a == b) { print "Power bound error!" exit; } }; function bound_rate(a) { if(a > 8.575) return 8.575; if(a < 0.05) return 0.05; return a; }; function round(x) { ival = int(x) # integer part, int() truncates # see if fractional part if (ival == x) # no fraction return ival # ensure no decimals if (x < 0) { aval = -x # absolute value ival = int(aval) fraction = aval - ival if (fraction >= .5) return int(x) - 1 # -2.5 --> -3 else return int(x) # -2.3 --> -2 } else { fraction = x - ival if (fraction >= .5) return ival + 1 else return ival } };