New User Special Price Expires in

Let's log you in.

Sign in with Facebook


Don't have a StudySoup account? Create one here!


Create a StudySoup account

Be part of our community, it's free to join!

Sign up with Facebook


Create your account
By creating an account you agree to StudySoup's terms and conditions and privacy policy

Already have a StudySoup account? Login here

Computer Methods in Biological Engineering

by: Laverna Wisozk

Computer Methods in Biological Engineering BAE 200

Marketplace > North Carolina State University > Applied Biological System Tech > BAE 200 > Computer Methods in Biological Engineering
Laverna Wisozk
GPA 3.87

Michael Burchell

Almost Ready


These notes were just uploaded, and will be ready to view shortly.

Purchase these notes here, or revisit this page.

Either way, we'll remind you when they're ready :)

Preview These Notes for FREE

Get a free preview of these Notes, just enter your email below.

Unlock Preview
Unlock Preview

Preview these materials now for free

Why put in your email? Get access to more of this material and other relevant free materials for your school

View Preview

About this Document

Michael Burchell
Class Notes
25 ?




Popular in Course

Popular in Applied Biological System Tech

This 126 page Class Notes was uploaded by Laverna Wisozk on Thursday October 15, 2015. The Class Notes belongs to BAE 200 at North Carolina State University taught by Michael Burchell in Fall. Since its upload, it has received 20 views. For similar materials see /class/224010/bae-200-north-carolina-state-university in Applied Biological System Tech at North Carolina State University.


Reviews for Computer Methods in Biological Engineering


Report this Material


What is Karma?


Karma is the currency of StudySoup.

You can buy or earn more Karma at anytime and redeem it for class notes, study guides, flashcards, and more!

Date Created: 10/15/15
BAE200 Week 13 Lecture Excel 2007 111808 Ambient Particulate Matter Concentration Determination Dr Lingjuan Wang 0 PM and National Ambient Air Quality Standards NAAQS Particulate matter PM is one of the six criteria pollutants listed in the NAAQS Particles with an aerodynamic equivalent diameter AED less than or equal to a nominal 10 um also known as PM and 25 pm PMZS are the currently accepted indicators for PM pollutant The NAAQS mandates that public exposure to the 24hour ambient concentrations of PM and PM should be no more than 150 pgm3 and 35 ugmg respectively 0 Particle Size Distribution PSD One of the most important characteristics of suspended particles is the size distribution of the particles The lognormal distribution has been used extensively for particle size distribution PSD because it fit the observed size distributions reasonably well A lognormal distribution can be characterized by two parameters mass median diameter MMD and geometric standard deviation GSD For a given PSD given MMD and GSD mass fraction of PM is defined as a cumulative fraction of particles less than or equal to 10 pm on the cumulative lognormal distribution curve It can be calculated using Excel function as shown below PSD with MMD 18 um and GSD22 Diameter um D Cumulative fraction Mass fraction of PM 150 00008 200 00027 139 Go to excel Function statistical 33900 0390115 quotLOGNORMDISTquot 350 00189 400 00282 450 00394 500 00521 550 00663 1 LOGNORMDISTDLNMMDLNGSD 600 00818 650 00982 700 01155 750 01334 800 01519 850 01706 900 01897 950 02088 Mass fraction of PM 1050 02471 1100 02661 0 Ambient PM SamplingMonitoring Low volume LV total suspended particulate TSP sampler has been widely used for ambient PM sampling As shown in figure 1 the LV TSP consists of a TSP inlet head with 47 mm filter holder and a flow control system TSP iulel head Viilh 4 mm Flllel Holder sump Edge Olit iee Meier H Diaphragm Pump N erdle Valve Pl assure Transducer Mugueheljc Gage Dam Loggel Figure l Low volume total suspended particulate sampler system In this sampling system the pump pulls the PM entrained air through a TSP inlet and then through a Teflon filter The PM which penetrates the TSP inlet will be captured on the filter and the filtered air will be discharged An orifice meter is used to monitor the flow rate at 1 m3 h 167 lmin by monitoring the pressure drop across the orifice meter The following equation is to use to set the proper pressure drop across the orifice meter based on the target flow rate Q1252104 KD g Slunits 1 Where Q airflow rate through the orifice meter m3 h39l K flow coefficient dimensionless D7 orifice diameter m AP pressure drop cross the orifice mm H20 pa air density kg mg or Q 5976XKXD English units 1 pa Where Q flow rate through orifice in cfm D0 orifice diameter in inches AP pressure drop across orifice in inches of water pH air density in lbft3 The pressure drop across the orifice meter is measured with a pressure transducer A data logger is used to record the output from the pressure transducer This output is used to calculate instantaneous volumetric flow rate A magnehelic differential pressure gauge is also used for a visual check of the pressure drop across orifice meter during the sampling period A needle valve in the sampling system is used to adjust the flow rate to keep a constant volumetric flow of 1 m3 h through the sampler inlet when change in the pressure drop across orifice meter is observed Air temperature and relative humidity are monitored by a Psychrometer for calculating the air density Combining this density and the pressure drop measured by the pressure transducer or magnehelic gauge flow rates is calculated using equation 1 to determine the total volume of air pulled through the system during sampling period This flow volume is used to calculate the PM concentration that penetrated the TSP sampler inlet head preseparator as following Wf Wi COILTSP W 2 Where Conn TSP concentration pgm3 W filter preweight ug Wf filter postweight ug Q sampling system air flow rate mgmin t sampling duration min The system sampling flow rate Q may be calculated using equation 1 In the absence of pressure transducer the magnehelic gauge readings will be used for flow rate calculation In such case the beginning and ending pressure drop readings will be recorded for the flow rate calculations The flow rate Q for the concentration calculation equation 2 is the average of the system beginning and the ending flow rates In addition to federal reference method FRM for PM and PM sampling there is an alternative way to determine PM or PMzsconcentration by combining measurements of TSP concentration and PSD of the PM in question The true PM10 or PM25 concentration equals the TSP concentration times the mass fraction of PM or PM25from PSD analysis ConPMIO Comm PM10 3 COH39PMZS conTSP PMzs Where Conmm PM concentration pgmg PM10 mass fraction of PM determined by PSD see PSD session for determination PM25 mass fraction of PM determined by PSD see PSD session for determination Laboratory Case Study DUE MONDAY NOVEMBER 24 at 1200 noon Submit to WolfWare unitleHmk13xlsx Part 1 Particle size distribution PSD for various environments Develop three cumulative lognormal distribution curvesplots which represent three PSDs in mass under various environmental conditions Question 1 Examine cumulative PM25 and PMlO mass fraction Which environment gives the highest PMlO and PMZS Explain why Part 2 Particulate matter PM concentration determination You work for the Division of Air Quality of NCDENR and are responsible for reporting the 24hour ambient concentration of PMlo in Raleigh A PM sampling campaign was conducted at a broiler facility in Raleigh area to determine the PM concentration TSP sampler was used for this sampling event The air density was determined to be 0074lbft3 during the sampling period The sampling data are included in the following table Orifice KO676 D0 316 inches Beginning Ending Unit Sampling time 1030 1330 Filter weight 720945 72 120 1 g Ori ce AP 127 115 In H20 After the sampling event the PM sample on the TSP filter was analyzed for PSD using LSl3320 multi wavelength laser diffraction particle size analyzer It was determined that this broiler PM sample has a PSD with a MMD 25 um and a GSD16 Determine the following 1 The TSP concentration in ugm3 2 The measured ambient concentration of PMlO in ugms Is this within 24 hr NAAQS for PM 3 The measured ambient concentration of PM25 in ugms Is this within 24hr NAAQS for PM NOTE39 As with all assignments in Excel 2007I make sure you include a title page including the answers to the 39 title for all 39 L inputs outputs and 39 39 named cells and 39 using named units and well 39 tables and plots Solution Hints Step 1 Determine the net mass of sampled PM on the filter Amass W Wi Step 2 Determine air flow rate Q of the sampling system using equation 1 This is accomplished by assuming Q Q avg Qi QflZ Convert from English to SI units Step 3 Determine the TSP concentration using equation 2 Step 4 Determine PM and PM 25 mass fractions through PSD analysis by generating a cumulative ognorma distribution curve with MMD 25 um and GSD 16 see part 1 of the case study put this distribution of the Part 1 Worksheet Report the PM and PM25fraction from the curve as a decimal equivalent and report it as a Step 5 Determine PM and PM concentrations using equation 3 Note use PM as a fraction in the equation Step 6 Compare calculated PM and PM concentrations with NAAQS and answer questions BAE 200 Computer Methods in Biological Engineering SZsEIS Instructor Dr Mike Burchell Class Imvudumun 1 Why is this class important El It will provide you with a basic skill set and reference material that will help you apply problem solving techniques for 1 Future undergraduate BAE classes 2 Engineering firms SZeEIE Class Imvudumun 2 Course Objectives By the completion of this course you should be able to do the following things H N 9 5quot List and apply the steps to Engineering problem solving clarly identify inpuis and outpuls required for solving engineering problems Develop and test solution algorthms in tially by hand utilize computer programming techn ques to implementalgortnms thatare more complex or require numerous inputs Effectively utilize MATLAB TKSolver and Excel 2007 for problem solving data analysis and grap cal represenlaton of results SZeEIE Class Imvudumon a Effectively utilize software El Identify strengths and weakness of each software El Good programming practices I ie logic naming conventions units significant figures comments general organization El Debugging El Effective communication of results I ie descriptive and clear graphs and tables clear engineering communication mama Class Imvodumon Syllabus El Highlights El 5 Minute Activity l pair up and read through formulate questions mama Class Imvodumon Class text El There will be two bundled textbooks for this course ISBN 0558022227 Cost 9100 1 Engineering Analysis and MATLAB 7 by Etter ncicky Moore Hagen and Hart 2008 2 Engineering with Excel by Larson 3rd Edition arson Custom Pu lis ing El Laboratory materials for the Excel portion of the class will be provided at no charge El Text was designed to be a good resource for the remainder of your classes mama Class Imvodumon Software for PC use El MATLAB R2007a l lthttpwwweosncsuedulsoftwarelinstalll El TkSolver not needed El Excel 2007 buy for laptop recommended already form COE mama Class Imvodumon 7 Cou rse Expectations El During Class El During Lab El Submitting Assignments El Exams El Grading El Academic Integrity mama Class Imvodumon a Course Expectations Class El Be familiar with reading assignments El Attendance Required 10 El Contact instructor if need to miss El httpwwwncsuedupoliciesacadem iciaffairspolsiregsREGZOS004php El Be Prompt El Laptops will be required for portions of the class no surfing please see NOMAD access mama Class Imvodumon 9 Course Expectations Labs El Be familiar with reading assignments El 1105 Grinnells El Workspace lockers mama Class Imvodumon 1n Course Expectations Assignments El Special assignments or Handwritten assignments due at beginning of following class period El 12 NOON deadline on due date for electronic submissions generally MONDAYS El Submit to Wolfware l LastnameiHWKldoc l LastnameiLABZxls 10 deduction per 24 hours until Thursday Greater than that will receive a grade0 El mama Class Imvodumon n Course Expectations Exams El 2 exams administered in class section El 1 programming lab mama Class Imvodumon 2 Course Expectations Grading El Attendance and in class activities 10 El Labs and homework 25 El Semester Exam 1 15 El Semester Exam 2 15 El Lab practical exam 15 El Final exam 3 hrs 20 mama Class Imvodumon 13 Course Expectations Academic Integ rity Encourage you to work together in labs All assignments must be turned in and be representative of your OWN work Cheating will NOT be tolerated At minimum the students will receive a ZERO for the entire assignment or exam h pwwwncsuedupoliciesstudentiservi cesstudentidisciplinePOLl1351php El EIEI El mama Class Imvodumon u Assignment Due Thursday August 28 Subm t first 2 questions in a Word Document on WolfWare Last Name Hwk1d0c El Answer the following questions List three goals you would like to achieve during this class 2 What are your expectations of Dr Burchell this semester What are the positives and negatives you have heard about this class be honest but no wise cracks Use anonymous feedback email Lu mama Class Imvodumon 15 BAE 200 Computer Methods in Biological Engineering Instructor Dr Mike Burchell mm m w MAME znmnmem 1 MATLAB El Mathematical Computational Tool El MATrix LABoratory El Matrices used to solve systems of equations it is a powerful way for storing displaying and manipulating 39n 0 about linear systems of equations Can be used by mathematicians engineers physicists and biologists to study complex phenomenon El mm m w MAME znmnmem 2 MATLAB El Can perform functions present on u scientific calculator but that is the tip of the iceber Can take the place of highlevel programming languages such as C and FORTRAN in scientific and engineering computations Its power lies in the MATLAB programming commands that are similar to the way we express mathematical expressions El El mm m w MAME znmnmem 3 TODAY Intro to the MATLAB Environment CHAPTER 5 El We will discuss l MATLAB Windows Section 51 Oommand Win ow Current Directory Window Document Window Graphics Window Edit Window Start Button new feature Arranging windows 0989999quot suyua 1m w MATLAE znmnmem o MATLAB envrionment suyua Command Window El Similar to the way your calculator works El Referred to as a scratch pad in the text because you can just start typing commands and out puts will be displayed El Uses algebraic order of operations so it is important how you type equation in El Commands are case sensitive suyua 1m w MATLAE znmnmem s Command Window Activity 1 El Type a few calculations in the Command Window I 52 l cos pi I 1oA5 I 102 I 102 SDWDE m w MAME znmnmem Command History Window El Command History Very important window Records commands issued in command window Will not delete until you ask it to Will be available to you the next session Can transfer any command from CHistory to CWindow by clicking will execute or dragging have to hit enter to get it to execute El EIEIEI SDWDE m w MAME znmnmem Command History Window Activity El Activity 2 Try clicking and dragging some commands from the Command History window you have used and get them to execute SDWDE m w MAME znmnmem Workspace window El Keeps track of variables defined as you execute commands 39n indow Clicking on the bar reveals more info Variabls listed as doublequotarray has to do with the oubleprecis on floating point since MATLAB was developed in the language C Activity 3 Enter in the following wriables and see what happens in the Workspace window A 5 l c 1 2 3 410 20 30 405 10 15 20 semicolons here separate rows El Notice it lists the variables as matricE a 1x1 is ns dered a scalar El Try moving windows around to yourliking DU U mm m w MAME znmnmem 1E Workspace Window Activity 3 El Activity 3 Enter in the following variables and see what happens in the Workspace window I l C 1 2 3 410 20 30 405 10 15 20 semicolons here separate rows El Notice it lists the variables as matrices a 1x1 is considered a scalar El Typing the command whos in the command window will list variables the command window DO THIS mm m w MAME znmnmem n Current Directory Window and Drop Down Box in the lab your arEWSEEEmn 5 El n change I Drop down list I Browse button Inext to drop down ist mm m w MAME znmnmem 2 Document Window El Can display the array editor El If click on existing variable the editor will appear and you can edit the array El Can also create a new variable El Good for entering or editing large arrays SDWDE m a MAME m Document window Activity 4 El Open the variable C in your command window take off the colon El Open Document window and click on your C variable to see the array editor open El Enter in additional values El Repeat top step and see the difference SDWDE m a MAME znmnmem u Document window Activity 4 I Click on new Variable icon and name the variable D I Click on the block next to D that opens the array editor I Give the variable a number then hit enter the type the variable in the command window and hit enter should give you the value you entered in the array editor SDWDE m a MAME znmnmem 5 Graphics Window El Will pop up when create a plot El Activity 5 Create an array ofx and y values in command window X 125341 Y Ia2030401 plntmy Note El suppresses output in command window S acs or commas OK for entering data A new graphics window should open We will learn in lab how to label axes SDWDE m to MAME znmnmem as Edit Window mFile El This window allows you to type and save a series of commands without executing them in MATLAB El From toolbar l Filea Newgt mfile El From Command line I Type edit SDWDE m to MAME znmnmem 17 Start button El Lower left hand side of MATLAB window El Toolboxes windows help function Internet products SDWDE m to MAME znmnmem 1E Personalizing windows El CORRECTION in text Personalize windows you prefer open by using Desktop from the Menu bar not View El Try moving windows around to your liking suyua 1m w MATLAE znmnmem BAE 200 Week 4 Lecture notes 91608 MATLAB Programming Engineering Analysis and MATLAB 7 Chapter 8 p 233 240 Goals 1 Comments about Homework 2 2 Present concepts of Looping and examples Notes When we started MATLAB we started with the SEQUENCES which were just a series of commands executed one after another Last week we introduced a selection structure that allowed for relational or logical operators to drive the direction in which the program proceeds Examples of these selection structures If we need a program to proceed multiple times consider using a Repetition Structure Repetition Structures also known as a loop causes a group of statements to be executed multiple times if needed The number times executed depends on a counter or a logical condition Understanding looping is required for fundamental understanding of programming 1 Loop can be executed 0 1 or multiple times depending on a counter or logical condition Loops Two types For end loops p 233 Used when you know how many times you need to repeat a set a commands gt SYNTAX For index expression generally a vector and the statements are repeated as many times as there are columns in the expression matrix MATLAB statements instructions that will be repeated end gt Any variable can be used as a loop index statement but k is often used gt k is an integer gt It is in the form k initial valueincrementlimit value looks like when we generate a vector matrix Examples ifwe consider k 12100 the value ofk can be l357 99 k 02100 the value ofk can be 02468 100 k 05100 the value ofk can be 051015100 kl 100 notice no value for increment used If no value used for the increment MATLAB assumes this value to be 1 so k 1234100 gt Activity 1 p 233 Demonstrate a for loop to calculate 5 raised to the 1003911 power total 1 sets an initial condition for kl 100 total total5 do not suppress the output here to see how it runs end Now suppress the output of total then type total It should give you the nal answer of 5100 What is the value of the index at the completion of the loop gt Study the for loop rules p 234 I While end loops p 236 Used when you don t know how many loops are needed but need to stop execution only when a certain condition is met gt SYNTAX while expression generally a vector and the statements are repeated as many times as there are columns in the expression matrix MATLAB statements instructions that will be repeated end gt The initial condition and the counter xl This speci es an initial condition while xlt15 This is a conditional expression MATLAB commands xxl While the conditional statement is satis ed the counter is increased by one for the next loop within the loop Note how you have to assign a value to x before you start the loop Unlike the forend loop the variable s value has to be rede ned within the loop In the whileend loop if the conditional statement is written wrongly such that it is never false say xgt05 the program will keep on running this is an inde nite loop To break an inde nite loop use CTRLC or you can specify how many loops to perform gt Practical Example Recall the Kure Beach example used in the lab about checking the sampler at the Kure Beach Dune In ltration system We assumed that Paul would go down once and make a decision of what to do based on several factors time of day rainfall received etc AS it turned out the lab was open that day So what if Paul wanted to check the site MULTIPLE times on an hourly basis He would leave the Public Works Department go down to the site check to see how much it had rained then either sample or return back to the of ce If it never rained at 300 pm he would shut the system down Assume this Program starts at 8 am at Kure Beach time8 sets the initial condition 8 means 800 am while timelt15 1500 means 1500 hours or 300pm ifrain gt 025 Collect sample Deliver sample to Tritest Shut off power to sampler Leave power on to measure ow time 1 5 end time imel end Go home to escape Hanna End of program More ill depth discussion of m loop indexing if time permits 1 Traction and Tractor Drawbar Power Static Ballast of Tractors a Percentage Weight distribution Roberson GT 1992 and Taylor 2002 5 Fvyuwl sunwunmulsvnwmnwnw mealarm mm 407457 5545M mum mumsle 1mm mam lmlw 5 407457 mm 51mqumluwnnnwuw Mumm vnlmL b Ballasting for 2Wheel drive tractors that can be adapted for front Wheel assist tractors Roberson GT 1992 Ballast depends upon soil conditions ground speed hitch and drive con guration Table 1 Ballasting TwoWheeI Drive Tractors Total Stall Welght on Drlve Wheels on Tuned Sol at 12 Percenl Wheel Sllp 80 Percent Load Noland Ground Peed mph Mounted Implement Total Rear Axis Walghl lbmed PTO hp Snmlmuunled lmpllmem Towed Implemunl 2 204 4 102 6 68 8 51 233 265 116 134 78 90 58 57 Z Llne 0 Km I C Pull X 2 Drawbar Full and Weight Transfer m gum mz F 7 m 1 1Cl 12 I1 1 tatic rear wheel heaeh39Oh kN lb Rf static front wheel heaeh39Oh kN lb Rm motion resistance force kN lb Rn much fome kN lb 7 chem of drawbar pull kN lb m tractor mass Mg g accelera ofgravity 9801 msz x eel ase mm in distance between d1 rear axle centerto vehicle center ofgravity mm in quot 39 39 39 39olel39 I II mm mm i f front wheel h rear wheel Empirical method using dimensional analysis and soiltire data to develop a traction model Refer to free body diagram of tractor pulling an implement Gross traction ratio Cgi T Cgi 0880 6013 l e k sk2 13 rLl R1 Bni dimensionless wheel numeric k1 75 bias 85105 radial k2 004 bias 0030035 radial S slip decimal T torque Nm rLi loaded tire radius m R dynamic vertical reaction kN 5 5 l h Clibidi i Bni 3 14 1000 R1 1 FA CI cone index Nmmz bi tire section width mm d wheel outside diameter mm 5 tire de ection mm hi tire section height mm rA aspect ratio 085 Motion resistance ratio p 15 where k3 l0 bias 09 radial Tire Parameters Rear Wheel dr 254dnr 2 rA br d wheel outside diameter mm d r nominal rim diameter in br tire section width in d rLr 254081rAbr rA aspect ratio 085 5r loaded tire de ection mm 5r dr2 rLr rLr wheel static loaded radius mm hr dE 7 254 dEr hr wheel section height mm 2 Net traction ratio Cu 16 Using the preceding equations the tractive performance of a wheel or a vehicle can be calculated using an iterative procedure Then th Cnr Rr Cnf Rf Note Cm is per wheel 3 Tractive ef ciency ability to transfer power from the aXle to the drawbar through the tire and soil Tractive ef ciency depends on slip set by ballast soil conditions tires and drive con gurations Tractive ef ciency TE Power out Power in TE R RV 1 SC 18 P T1601 C an gr where PM net traction power of wheel kW Pm axle power of wheel kW oi rotational speed of ith wheel 4 Wheel Slip S loss in forward ground speed but is usually measured by loss in forward travel distance where Vt theoretical velocity Va actual ground speed Table of slip for optimum power transfer from axle to soil Roberson 1992 Surface Soil Condition Wheel Slippage 1 Concrete 48 Firm 810 Tilled 1 113 Soft and Sandv 1416 If you can observe slip it is usually greater than 25 and is too much 031 qua I Cni 0 01 02 03 04 05 06 Wheel SlipS Net Pull of 8 Driven Wheel x 1 0 01 02 03 04 05 06 07 Wheel SlipS Tractive Efficiency Slip Relation 0 0 02 03 04 05 06 07 Wheel Slip S Tractive Efficiency Design Curve 5 Estimating tractor PTO power needed for drawbar operations a Drawbar power P DB Where FDB drawbar pull lb Va vehicle actual ground speed mph Where FDB kN Va kmh b Equivalent PTOpower Pmo EQ since tractors are rated at the PTO and not at the drawbar Where 096 virtual gear losses from axle to PTO sha Problem Given data from the Nebraska Tractor Test summary for a John Deere 4755 QUADRANGE 16 7 SPEED 2WD Using this information and the assumption the tractor is operating on a soil with a cone index of 15 Nmm2 and a level drawbar load calculate the maximum drawbar pull that can be produced by the tractor operating at a wheel slip of 10 Plot the TE versus slip S and the TE versus the net traction ratio Cn for wheel slips ranging from 0 to 50 What are the approximate values of wheel slip and the net traction ratio for peak TE values Ballasted Weight Tire and Chassis Data Static Weight 7 Rear Rm 15450 lb 7008 kg Front Rfo 4870 lb 2209 kg Total 20320 lb 9217 kg Height of Drawbar 2 225 in 572 mm Wheelbase x1 1185 in 3010 mm Rx fol x mm 2 W Rear tires 7 radial ply br 208 in d r 42 in Note The static weight information in SI units kg is mass The force kN is mass times gravity 9801 divided by 1000 Agricultural Air Quality In Ac nn nan Wang PhD E Assimm Prm39essnr inAir Quality Engineering Depaltment or Enlngjczl amp Ayiculturzl Engineering NC Smte University Nuvl zma BACKGROUND Air Emissions from Animal Feeding Operations AFOs a EmlogmxlMdAgnmlmmlEvgmunng Norm manna SlazaUnlvcmty E Ki nanMalawiaawMManama E ONGOING PROJE CTS PROJE CT Nau39onaiAir Emissions Monitoring Study NAEMS Somheast Layer Site NCZB Site OuiFaml Instrument Shelter OHS collection sinned in Sepiember 20039 1 s gig WWWWIEmng Mumm amp PROJECT 2 Characterizations of PM from Egg Produc on Faciliu39es Source versus Public Exposure 5101051511111 AgnmlemlEngmuvmg ohm sum Unlvsmly Envimnnmhl Sum EhmnMimtwewizhmlInn D39I39pznie Xrny mtEsmEDX Modding Ammonia Emission from Broiler Litter PROJE CT 3 1 Wme WW M WWWWW Objectiv 1 Characterizetherumprehensiveimpzn m39litter me No pH air speed nn NH vnlatilizztinn 2 Estimate mass transfer cnd39 cientfm NH emissinn frnm may um Fim pmnuiwn39immhl m i ux dunth ijaclperizd Augug ms 7 Demmhzr 2m magnum AgriculmmlEnginzzring North Cumin Store Univzmity m BiologicalMdAgriLulmmlEnginzzring Norm Carolina State University a Independent Study BioiAerosol RespondingNotifying System BARNS Field Evaluation of Ozonation Technique for NH3 Emission Control in Broiler Houses l Bio031mlandAgrkulrumEnginzzring North Cumin State University amp I mm can I l Ammonia Measurements 4amp1 or more continuous measurement per Week m WWW One PMU per house quotQ Wemmmmo ll quotquotl alums lmu I ms Homewm Omquot Introduction to TK Solver Universal Technical Systems Inc Introduction to TK Solver Thls document beglns wlth a rapld tour ofTK Solvers lnterface solver and programmmg ht be used ln a tralnlng sesslon TK Solver can do such a broad varlety of thlngs that lt s best to be equlpped wlth the fundamentals rather than try to master the concepts from worklng examples features as mlg A glven problem mlght be solved ln a varlety of ways 7 paper and pencll calculator spreadsheet programmlng langua e math program 7 but TK Solver ls the best way to bulld a Versatlle solutlon That ls once a problem has been solved by bulldlng a mathematlczl model TK related problems can be solved wlth very llttle addltlonal effort That wlll be a recurrlng theme of thls lntroductlon At lts core TK Solver ls a rulerbased problem solvlng and math modellng envlronment that d E E mblnes equatlon solvlng unlt converslon lnterpolatlon es an userr e ned procedures The rulerbased features can be accessed from a varlety of problem solvlng and Llst Solver can be used to repeatedl process the math model over ranges of lnputs to generate tables and plots of solutlons The llst solver can also be use ln Monte Carlo slmulatlons lterlng dlstrlbutlons of random numbers through the rules and summarlzlng the results An Optlmlzer can be used to repeatedly process the math model untll some target solutlon ls achleved sublect to bounds and constralnts on any varlables and expresslons An Excel Toolle allows any ofthe oblects varlables unlts llsts plots from aTK model to be lnteractlvely llnked vnthln a spreadsheet hese o lects can also be llnked lnteractlvely wlth custom desktop and webrbased appllcatlons created uslng other programmlng languages WWW ms 115com 1 The Interface TK Solver mmnges chtrexeht types of oblects oh worksheets The obea types us mles vmzbles hsts umts plots mbles fox mnts md comments Together the oblects om form 1 mhthemhtml model The worksheet stmotme ls nccessxble m the TK N vlg llon Bu If e you do not see th N vlg llon Bnr chck oh the mew menu to ncnvnte tt AL Meeet Vanah es Mes res Funttmns E umt rai Usts P hts ethtaa m g Yulana s E C Dammentatmn 3 whet Doublerdxck oh the won or descnphoh of the sheet you need to nccess If oblects zlxendy present m i TK model the ngmoh Bnr dxsplnys quot1 symbols besxde the sheet s Click on the quotw to Expnnd the dlsplm md show the oblects oh thht sheet If you A221 Vanah es wwm 1115115 cum 2 You can also access an obect s properties cluectly from the worksheets holdmg both the keys Ctxer or by ughtrdlckln g on the oblect TK also promdes nccessto emshng obects m amoclelylathe Oblect Bnr l Ms From the M1 th e Obea Bnr icons access ttmctlons lasts plot de mtlons table amnltlons md tozmat de nmons The Obea Bnr also provldes quick access to emstlng plots tables md comments Use the Naylgatlon Bu to access TK sheets md aeate new oblects Use the Oblect Bnr to access emshng obects Navigation Mode vs Edit Mode en you type mfoxmnllon into a TK sheet TK goes into edit modti You see a smgle nuer m m of TK s lntexfnce axe lnaccesslble You wlll see that cannot change to ndlffexent sheetwhen you item echt a e the icons become gmyed out You mode A El m m I 2 E v lnls Ail When you have completed entry of the mfoxmnllon m a pnmculnx eld the blmlnng cursor dlsnppenrs and the cment eld is completely hlghhghted You axe now in hnvlgm od When you re m naylgatlon mode you have free access to all the lcons menus and lntexface fLm alonahty TK Soilax is a Tool Kit full ofmmy solvers that all Work together under your direction Here is a hst ofthose soilEn Duect Solvx LlstSolvex ItemnveSolvex mlzez Proceduxerocessox TKlemryofRootrFlndezs DifferentialEquntlonslntegmtor ExcelToolKit wwm 1115115 cam TK s Direct Solver performs inverse mathematical operations and inverts functions in an equation to solve for a single unknown If an equation contains more than one unknown the Direct Solver skips it and moves on When it solves an equation it applies what it learns to subsequent equations making additional passes through the rules to solve previously bypassed equations and checking for inconsistencies For example given inputs for any two of the three variables in the following equation TK s Direct Solver will solve for the remaining variable tandthem2 radiusheight or in TK s MathLook view tandl thgta lz radius height The Direct Solver makes your life easier by allowing you to enter your equations in any sequence and without having to isolate the unknowns to left ofthe equals sign TK s Iterative Solver works with the Direct Solver to solve equations where the unknown cannot be isolated or to solve systems of simultaneous equations The Iterative Solver sends a guess value to the Direct Solver which works its way through the equations until it detects an inconsistency in one of the equations The Direct Solver then tells the Iterative Solver how much of an inconsistency it found The Iterative Solver keeps sending the Direct Solver new guesses until the inconsistency is very close to zero The Iterative Solver can work with multiple guess variables if necessary For example the following set of equations can be solved using TK s Iterative Solver if inputs are given for theta and volume and theta radius 2 height volume 1 3 2 Tr radius height The Iterative Solver can also be used to solve problems involving more complex functions that are otherwise noniinvertible For exaInple the Iterative Solver can be used to determine the upper limit x2 of the following integral given the lower limit x1 such that a desired area is achieved Area IntegralC39lisinxcosxxquotx1x2 Similarly the Iterative Solver can backsolve the following rule to determine the pressure at which water vapor at a given temperature will have a given density Rho densitylt1 water TT PP WWWlltSllSCOm 4 TK Solver also includes a Procedure Language that allows for solving problems in a sequence of steps The procedure language is used to create useridefined subroutines called Procedure Functions Procedure Functions can be called as a subroutine by the Direct Solver to do specific tasks such as stepping through a range ofinputs lling lists performing summations or products etc Procedure functions allow you to add any algorithms to a TK model Given an input value for C the following procedure loops through a series of calculations returning the final value of S and generating a list called XYZ with the cosines of each of the 100 intermediate values of s S 0 For I 1 to 100 S S Cil10OOA72 XYZI cosS Neth Suppose we need the output of this procedure to be 275 and we need to know the value of C required to make that happen The lterative Solver handles it easily Some TK builtiin functions automatically generate lists of solutions For example TK includes a collection of integrators for solving d rmtz39al equations There is also a Wizard to help set up the differential equations initial conditions solution tables and plots As with procedure functions the Iterative Solver can be used to backsolve these integrators to achieve desired results Here is TK s solution to the following differential equations where y100 and y2002 Solution 1 WWWlltSllSCOm 5 TK also includes a List Solver that will repeatedly run the entire math model using lists of values for any of the input variables This is one way to generate tables and plots of results The List Solver can be set up manually or through the use of a Wizard The List Solver will call on the Direct and Iterative Solvers at each step of the process Here is set ofTK rules used to solve uid ow problems density DENSTY3 uid 39T T 39P P viscosity WISCOSIT3 fluid 39T T 39P P W q density 4 q V 39 2 Tr D NRe V density VISCOSIty 1255 1 e 4Iog 44 f 2 denap f density V L D 16085 ps 4D WWWlltSllSCOm 6 Here ls n plot othe pressure drop vs the tube dmmetee pressure drop p 1 lube dlamelev m Llst Solvlng cm 1150 be used to run through 1 531135 of mndom numbers from vmous probablllty dlsklbutlons I39hls ls cnlled Monte Cnrlo Slmulnllon TK s slmulmon lenxd can b used to set up all thexequ t e ued pnmmeters md evaluntethe xesul s The TK Optinnjzsrepentedly solves nTK model untll 1 set of obecuves He met Thls cm r n mt Solvers at ench step ofthepxocess an nn parameters elTalgelVanahle mam Mame rum ovum sueu u the WM 3925 Add l2 22 32gt l Dame BeselAu wwm 1115115 cam The Opumxzex can also be used as an alternauve to the Itemuve Solve for backsolvx g a model to detezmme h h ow ah moot must be changed so that one of the outputs results m a deehed wlue TK Solver mcludes a Ltbm h rhng models The Ltbmy accessed ma the Apphoottohe meho mcludes hundreds ry ofpxerpxogmmmed procedures yo e mto youh oWh of tools dmded mto wnous ootegohee ms Menhug system TK SUNS rm Wmdaws t 4 d Se echan n or 6 Add Bemwe REID IsnFEuuAnnNs meetth deemem mementoedemath at my meweml we e K bemry tools can be used to solve epeotho problem thhm a math model heemg other solvers to tackle other tasks The Ltbmy 0015 also add to the awxlable rootr fmde m TK He e ts a dutch summaryofthe rootrfmders m the TK Lt xary QuadmucEquauons Bteeottoh Method Cub E uauons aseposmon Method entoh e Method to QuarucEquauons Nth ohdeh Polynomhl Eduottohe by Bohetow e Method wwwms 115com You cm see these tools m aotaoh by londmg the examples from the TK lemry before mergmgm oneof the tools Fmally the mExcel Taalla39tpxovldes another level of solvlng power The TKrExcel oo lat allow o run my number of TK models as subroutlhes wtthln an Excel spreadsheet Th T cells cm also be referenced from other cells m Excel The outputs fom h cm be hhlred to the lhputs m other models The hhlred TK models cm be called to Llst Solve to genemte tables of soluhohs that cm also be hhlred wlth Excel The Here s apomoh of llnked spreadsheet showmg some TK vanables and a plot u aee avea utuulslde n le unhe uemn Sample smaee 115 225 335 4455 Yadlus m wwm 1115115 cam Practice Lefs begin with some practice with the interface Launch the prograIn Opening Sheets and Creating Objects 1 The toolbar automates several of the menu commands You can see tool tips by moving the pointer over the icons The Navigation Bar provides fast access to the various sheets Double click on a sheet name to open it Sheets can be minimized or maximized by clicking on the icons in the upper right corner of each window Alternatively windows can be closed by clicking the button in the upper right corners Open the Plot Sheet Enter p1 in the name column Move to the second row on the Plot Sheet and enter plot2 Now there are 2 objects FACT TK sheets can hold up to 32000 objects if necessary Name Flquot Plan 6 Title LIL Llne chart lpm 5 O Cursor down to the third row on the Plot Sheet and try to enter 2ndplot When you try to enter it TK displays an error message 2ndplot is an invalid naIne Click the ContextiSensitive Help button In this case TK displays complete information about how to enter naInes what characters are valid in naInes and other related information You can also search for other Help topics When you are finished exploring Help close it and return to TK Press Esc to remove your entry or edit the name so TK can accept it Press Home to move to the top of the Plot Sheet Home and End move you to the top and bottom ofa sheet Move the cursor to the Plot Type column Notice that if you double click in this field a pullidown appears Many different TK fields behave this way In this case choose Line Chart As a shortcut you can also type the first character of the choice you want At this point you have a Line Chart naIned p1 but you don39t have any contents for it yet data labels scales etc WWWutsusc0m 10 Opening Subsheets and Editing Object Attributes 1 Click the right mouse button or press CTRLrD to open the subsheet for the pi Line Chart Subsheets contain object de nitions N Enter abc as the XeAXiS List name TK created the object automatically on the List Sheet Look at the Navigation bar and see that a is now shown beside the List Sheet icon indicating the sheet now has content b0 Open the subsheet for the list abc CTRLiD or right mouse click on the list name in the plot subsheet or use the Navigation Bar A list of values can be entered here in the subsheet Enter 1 then cursor down and enter 2 then 3 then 4 then 5 under the Value heading The element column automatically updates to let you know which line you are on Most sheets don t have line numbers however you can look in the lower left corner of the TK screen and it is displayed regardless ofwhere you are in the prograIn 5 Close the list subsheet Ln Cursor down below the YeAXiS eld and enter xyz as the name of the YeAXiS List l YAxis l Style l Color l Thickness l Type l Charact lxyz l Lines l Blue l 1 olid l l W lltS as com I WWWlltSllSCOm Open the subsheet for xyz and enter the values 2 4 7 23 89 in the rst ve rows then close the subsheet Use the Commands menu and select Display Plot or press F7 TK used the objects we de ned and created a plot by connecting the XY coordinates with lines Here s the plot 90 80 7O 60 50 4O 3O 20 10 O I I 1 15 2 I 25 3 35 4 45 U1 Use the Navigation Bar to View the contents of the List Sheet The List Sheet is the storage place for any lists which have been created or imported from spreadsheet or ASCII les TK automatically placed the naInes abc and xyz on the List Sheet as soon as we de ned them on the plot subsheet Move the cursor over the xyz list and open the subsheet This works in every sheet allowing you to check or de ne contents There are several ways of viewing subsheets The object bar along the top provides pullidowns for each type of object Close the subsheet Next open the Table Sheet using either the Navigation Bar The Table Sheet is the place where tables are de ned and stored Just like the Plot Sheet or any other sheet we can de ne several tables on the Table Sheet Tables are collections oflists Enter t1 as the name of the rst table then open the subsheet to further de ne this new object 12 12 Enter the naInes of the two lists we previously created abc and xyz By default TK assigns column widths of 10 1 List 1 Format lWidthl Heading 1 1 abc l l 10 l 1 leZ l l 10 l l 13 Press CTRL D or the Right Mouse Button to open the Interactive Table Subsheet t1 14 These are the same values we entered earlier Let39s add another data point to our plot Move the cursor to the 6th row in the abc list and enter 6 Cursor over to the xyz list and add another value by entering 85 2 TK evaluates this expression for us In fact there is a calculator in every TK input eld Click on the down arrow in the upper right corner of the subsheet to iconize the subsheet 15 Use the Object Bar or Press F7 to bring the plot window to the top again It now displays all siX pairs of dam points 10 0I I I 1 15 2 2 U1 0 A 01 J 5 01 U1 U1 01 a 16 Pull down the Window menu and select Cascade This will help you see all the sheets and subsheets you have open You might also try the Tile option 17 Close all the Windows using the Windows Menu WWW lltS as com 13 18 Use the tables hsnng In the Oblect Bnr to open the table t1 The Oblect Bnr saves you th trouble of tanchhg md opemng mdmduzl sheets It also helps keep the mtexfnce 19 Use the Nnvxgmon Bnr to open the Plot sheet Htghhght the rst p1othame p1 Use the View Menu md select Pmpem es There x a1s an acoh avauable or u cm press N ft coma ofthe properties box to keep at on the scram as you move from oblect to oblect use em 1 o Propemes p oblea subsheets md wan dueouy nffect the oblect Press H to bung the plot p1 up on the screen ChcktheYLngselecuon mthePropemesBox The plot updates mu wwm 1115115 cam Equation Solving We begin with a very simple problem N b0 gt Ln 0 Enter the equation ab cd on the Rule Sheet TK automatically places the variable names on the Variable Sheet Variable names are case sensitive W a and A are not the same in TK Also notice that TK placed a quotW symbol in the smtus column next to the equation Move the cursor over the and note that the status bar at the bottom of the screen reads quotUnsatis edquot You may also click and drag on the column separator to expand a column Equations are also displayed in MathLook view at the bottom of the screen If the MathLook view is not displayed use the View menu to activate it Activate the Variable Sheet and enter values of 2 3 and 4 in the input column for the variables a b and c We now have one equation and one unknown Press F9 to solve or use the Commands Menu or toolbar icon TK displays the value of d 125 in the output column Also the disappeared from the Rule Sheet and rule is marked as Satisfied Look at the lower right corner of the screen TK displays the memory available along with an quotOKquot message OK appears after solving If any changes are made to the Rule or Variable Sheets TK changes the OK to F9 as a reminder Switch to the Variable Sheet and enter 15 as an input for d Notice that the OK indicator has changed to F9 Cursor to the input field for the variable a and press Spacebar and Enter to blank out the value Again we have one equation and one unknown Press F9 to solve The solution for a appears in the output column Switch back to the Rule Sheet and place the cursor over the equation Press F5 or doubleiclick to change to edit mode Edit the rule to read ab bc Switch to the Variable Sheet and enter inputs of 2 and 3 for a and c and blank out any other input values We have one equation and one unknown Press F9 andno solution If an unknown appears more than once in a rule TK s Direct Solver cannot solve it Move the cursor to the status column of the variable b and type G or doubleiclick and choose Guess to indicate that b will have an initial guess By default TK places the last value entered as the guess value or 0 if no value has been entered yet We can enter any value we choose as a guess Press F9 again and a solution is found b1 TK s Iterative Solver sent the guess value to the Direct Solver The Direct Solver detected an inconsistency and reported the value back to the Iterative Solver The Iterative Solver sent a new guess value and the process was repeated until the Direct Solver no longer detected the inconsistency Switch back to the Rule Sheet and enter a second equation ab 1 c This is a different version of the previous rule and none of the variables appears more than once Press F9 and TK solves for b directly with no guess needed WWW lltS as com 15 Now lefs practice with multiple equations Keep in mind that the same process is used TK will use solutions from equations in trying to solve other equations In general though TK cannot solve an equation directly if it has more than one unknown or the unknown appears more than once N b0 Ln 0 Use File New to reset all the sheets for the neXt lesson Enter the following equations on the Rule Sheet yl 3XA2 y2 XLNX 20X Switch to the Variable Sheet enter 50 as an input for yl and solve Success The first equation has only one unknown X which appears only once Once X is known from the first rule the value is used in the second rule to solve for y2 Now give y2 an input of 50 blank yl and solve No solution In this case the first equation has two unknowns so TK skips it The second rule has only one unknown X but it appears more than once so TK cannot solve for it directly Try a guess for X and solve again Success Try a different guess for yl and solve again Success again What happens when we guess The purpose of guessing is to temporarily reduce the number of unknowns in an equation to one TK can then solve the equation and move on to others if necessary Eventually TK will find an inconsistency in one of the rules and will then iterate on the guess value until the inconsistency is sufficiently small less than 1E1 by default Add a third rule yl y2 Blank out any input values We now have three equations and three unknowns but none of the equations has only one unknown so we39ll need to use a guess and iterate Does it matter which variable we guess See for yourself Some guesses lead to error conditions In this case if TK tries a value ofX which is less than or equal to zero it will report an error The second rule includes the eXpression LNX which is not defined for negative X values At this point let39s save our work Use the File Menu to Save As the file name WORKl TK saves all the sheets in one file Use File New to reset all the sheets WWW lltS as com 16 SP 1 ecial Topic Understanding TK s Accuracy Enter the rule a a1 Switch to the Variable Sheet enter an input ofl for a and solve TK reports an error TK s Direct Solver detects an inconsistency because 1 is relatively different from 2 Now change the input value to IE7 and solve again No error The two sides of the equation are within TK s Comparison Tolerance Use the Options Menu and choose Settings Change the Comparison Tolerance setting to 1E79 and solve again This time TK notices the difference In practice the default Comparison Tolerance of 1E76 works quite well However if you are working with problems involving very small or very large values you may need to adjust this setting Use File New to reset and we39ll move on Guiding the Iterative Solver 1 2 Load the WORKI file Activate the Rule Sheet and doubleiclick in the smtus column of the third rule to cancel it so that the two original equations are the only ones used Enter 50 as the input for y2 and blank any other inputs if there are any As we saw before if we try solving at this point TK s Direct Solver will fail A guess is required to launch the Iterative Solver We can automate that process One of the properties for a variable is a first guess value If the Direct Solver does not make progress TK looks for first guesses for any of the output variables and launches the Iterative Solver automatically Enter a value ofl as the first guess property value for X Notice that TK places an F in the smtus column for the variable Stats F First Guess 1 Now when we solve the Iterative Solver is automatically triggered WWWlltSllSCOm 17 Educated Guesses Remove the first guess from the X properties For some problems the guess value must be chosen carefully and may need to change as one or more of the inputs change This can be accomplished by introducing an iteration trigger variable and then adding a rule to specify the required relationship In this case consider the following equation Y1 y1g Y2 If ylg is assigned a first guess value of 1 then yl will start the iteration process with the same value as y2 What ifwe want to guess that yl is half ofy2 Use the rule Y1 Ylg YZZ As you can see the eXtra rule can involve any expression you like Real Solutions Only Please If a guess is provided but is not sufficient to solve a problem TK simply moves the guess value to the output field This may lead you to believe that solved the problem for you however it is merely one of an infinite number of possible solutions In situations where a default first guess is supplied as a variable property you may not even realize that the Iterative Solver was triggered You can turn off automatic iteration via the Settings menu Under that condition guesses must be provided manually by changing the status for one or more variables If you have used a guess trigger variable you can use conditional expressions to control when it will be used to relate two variables For eXaInple lfgiven y2 then yl ylg y22 else ylg 1 In this case the guess will only be triggered if an input is provided for y2 WWW lltS as com 18 The Optimizer A Different Approach to Equation Solving The Optimizer can also be used to find solutions to problems like these It takes a bit more effort to set up but it provides mo re control in the form ofbounds and constraints that are not available With the Iterative Solver To use the Optimizer you must have a license for the Premium Version ofTK Solver 1 Load the WORKl le 2 Activate the Rule Sheet and doubleeclick in the status column ofthe third rule to cancel 3 t so that the two original equations are the only ones used Input avalue ofl for the Variable x blank any other inputs and solve Status lnput Name Output Unlt Cumment l X W 3 W 1 Suppose we want to determine the value ofx that results in an output of50 for yZ Pull down the Wizards menu and launch the optimizer wizard Select yZ as the oblective variable with the goal to reach a value of50 Click Next zard um Desmntlnn l Maximize f Mimmize r Rearh a value nf Sn WWW ins 115com 5 Select x as the decxsxon vanable In thxs case there are no bounds equxred so we leave the gt and lt eld blank Chck Next 951m yuur danishquot variables ami their bwnds De crwptiun Name Curr enWamz T pa gt x 1 cm I 6 In thls case there are no addmonal constmnts so chck leshed to launch the Optxmxzez then chck Exxt to close the Xxzzzd and mew the solutxon m Agl l Set up ad i unalennstraims Ava uamex npue Avauame oumue Nam e u n Destrwutm Name Umt Desmuum v1 Expregsiun Expressmn 1 Reach a value Maxim ze 7 Min ze WWW ms 115com 20 Here ls the yanable sheet showmg the results from the Optimizer stems mm 2 395mm The Optimizer works as a shell Tromd TK Solver xepentadly trying new mput values solylng F9 and obsemng the results unnl the goal ls achleyed The Ophmlzer uses the ounent values of the declsaon yanables as lnmal guesses Dl rent stamng polnts mnyresult In dlfferent soluhons Addltlonal constmlnts can be e added to guldethe Ophmlzea In ndlng npmlculnx soluhon There ls a second way of aooesslng the OphmIZer set up screen 7 Commmds Setup l ea Opumz an 11 elTalgeWallah e ya UK geaelra Maxlmlze r Mhme r yelaear lan eneel nn parameters M Bmmds Basel All Help Delete The a more conclse mtexfnce Use whlchevex you prefer In elther case once you have set up the Optimizer for a pmlculnr TK model the con gurmon ls saved wlth the model Thls means that lf you make changes to the model you can automatlcallyxemun the Optimizebe pressing Fllwlthout haylng to go through the set up process each hme 7 Edlt the second mle as follows yZ mm 15x wwm 1115115 cam 8 Press F11 and the Optimizer nds the new value ofX Equation Solving Summary Direet 1 elver One equation one unknown appearing just once Automatically inverts functions wherever possible Uses results from equations in trying to solve others Makes multiple passes through the rules until no progress can be made Iterative 1 elver Sends guess values to the Direct Solver and receives inconsistencies back Iterates on the guess values until the inconsistencies are relatively small First guesses can be assigned as variable properties Guess triggers can be added for educated guesses Optimizer Repeatedly runs a model until an objective is achieved Initial inputs are used as starting guesses Allows for bounds on any of the decision variables Allows for constraints on any expressions in the model Quiz Practice Problem Solve the following equations for X and y for A 39 and B 075 A eXpX Xy B sinXy X y 1 Use the Iterative Solver Does it matter which variable you guess Do all guess values lead to the same solution 2 Use the Optimizer You can use either A or B as the target variable and add the value of the other variable as a constraint Use X and y as the decision variables Do all guess values lead to the same solution The solution values for X are 1466498 2031738 and 2206181 Did you nd all three Now let s see how we can use TK Solver to investigate sets of equations like these using ranges ofinput values in tables and plots WWW lltS as com 22 List Solving Llst Solylngls the tepeated ptooesslng of the mles oyet tanges of lnputs stoted ln Llsts Any Make sute the model solyes once uslng typloal lnput yalues Assooate Llsts wlth lnputs and outputs and guesses lfnecessary Flll the lnput and guess Llsts wlth yalues Use the Llst Solve command Let s try lt Load the XORKl flle agatn wlth the followmg two equataons yl xxz y2 x LNx20x Xe wlll use TK to Llst Solve and oteate a table and plot showtng how yl and y2 yaty as x goes from 1 to 10 1 Enter 2 as the lnput tot x blank any other lnputs and solye Oulpm I I 2 Assocute Llsts wlth each of the three Vanables by doublechcklng ln the Status column and chooslng Llst You can also type an Lto asslgn Llst status to ayanable Itls atoggle tumlng the Llst status on and off Llneat Sealan Mame FlHDDe r Llneav r FlHBy leD E r ngamhmlc f FluByBange r m an amen l l Slap sue r21 FlvslValue l LasWa ue m X Mm Max www ms 115 cam 25 gt Choose Linear and Fill By Step First Element 1 Step Size 2 First Value 1 and Last Value 10 Then click the Fill List button Ln Use the Object Bar or Navigation Bar to View the 46 values in the X list 6 Click the Commands menu and choose List Solve or press F10 TK solves the rules 46 times using each of the X values as inputs and storing the results for yl and y2 in the associated lists 7 Use the Navigation Bar to open the Plot Sheet Create a new plot called p1 and specify that X is the XiaXiS list and yl and y2 are the yeaXis lists View the plot via the Object Bar or using the Commands menu 1 2 3 4 5 6 7 8 9 10 8 Edit the properties of the plot to add labels and indicate which line is which y1 and y2 300 M U1 O M O O O O U1 O U1 O 9 Follow similar steps to create a table displaying the three lists together WWWlltSllSCOm 24 The List Solve Wizard The previous example took genemte plots md tables o us through all the steps lnvolved tn usthg Ltst Solythg to f solutaohs Good news mah y of these steps have been automated yta the Ltst Sellax lenxd 1 Use Flle New to xesetTK md enter the mley smdx oh the mle sheet 2 Enter an thput of 30 for x on the yanable sheet md solve F9 3 Use the Ylznxds menu to launch the Ltst Soilax lenrd As you cm see the rst step ts to nke themodel solves for a sthgle value md you have nlxendy done that Llat Solving Wizard Before using this wizard Place all lhput values uh the Vatlahle sheet and sulve the mudel Make sute that the mudel sulves sueeesstullv Wlthuut h heeulhg a guess value tut uhe utvuutl uts Thls ee sulve lta guess ls YEqulYEd euhsluet uslng the Fltst Guess eld uh the vallable s suhsheet wwm 1115115 cam 4 Ptess Next to oonhnue to step 2 Vanzble seleouon In thts example we have ust one tnput and output to choose torn but you can stote as many outputs as you hke It is dunng thts step that TK ls assoclahng hsts wtth the selected ynnnbles st snlv w z nr 4 Select Your Vlrllblas SEMI one am Input vanab es nvev mg yange uwhtch ynu want 10 s salve M I Wyuu wt h Then lmk he Updam hunun In refresh Ihvs sclsen sum lnpm unmmm m Valiahll x v u late Oulpul Depemlem Variahl s mu Devandznt Vanab 5 Chck Next to proceed to step 3 fllhng the tnput hst Choose Linear and Fm By Step wtth Step stze 3 FustValue 0 and LastValue 360 WW l d LmEarSEahng t Lmeav r rtuaygtep auther r FmB Ran e r pituth m ttstetmentlt SlavStzeIS FusiVa ue lu LastVahe 3935 X Mm Max www ms 115 cum a Chck Next to go to the 4 md nal stepnnm1ngthexesulnnguble md plot List Solve Complete Wynn wam m mam a lame mum va ues and pm We va ues m a Lme char check yum pvefevences be uw and NEH bu un chck m x Tame x mm saw an EX SHHQ tame m saw an EX SHHQ Lme ype m a new name man tupe m a new name U v p v Ein um 7 Chck Next to dosethewxznxd md mew thetnble md plot wwm 1115115 cam 27 List Solving With Iteration Ifiteration is required during List Solving you must do one of the following provide a list ofguesses variable status LG provide a default guess value on the variable subsheet variable smtus L extrapolate W use the previous solution as the next guess advanced This topic is covered in detail in the Advanced Training document but the concepts aren t particularly difficult Guess extrapolation in list solving involves the use of the ELT and PLACE functions to determine the current element number during list solving and place the current value into the subsequent element where it can be used as the next guess Here is an example assuming the smtus for variable x is LG place xelt 1 x If the x list has an initial guess in element 1 this rule will place the computed value into element 2 Higher order guess extrapolation is also possible using similar logic Units and Conversions Open the View Properties Dialog for this section Be sure to click the thumbtack icon in that form to keep it visible 1 Enter the rule area length width 2 Switch to the Variable Sheet and enter input values of3 for length and 4 for width Solve and TK tells us that area is 12 The units are implied by the equation WWW lltS as com 28 3 Let s tell TK to do the Calculmon m lnches Move to the unlt column md Enter m for both length md wldLh md mAZ for men See the pmpemes for the vmzble n31 Both the cllsplny md Czlculntlon umts us Llsted is mAZ Iquot guess Fllsl uess 4 Open the Unlt Sheet md de ne nunlt conversion In the From column ants m In the To column enter cm In the ulhply By column enter 2 54 Add onset omen 5 sheet md ants on is the unlt for length TK nutommczlly chmges e Vnmble the value m the lnput eld The Czlculntlon umtls snllmches lnbut the cllsplnyls now Gentlmeters on wwm 1115115 cum 5 r 22 TK places a Thrs rndrcates that TK does not know the conversron trorn mAZ to anAZ Fusl Quess Ea cu ahan um r mat Go to the Umt Sheet md enter a second conversron trorn mAZ to anAZ Enter 2 54A2m the Mulhply By column 30 to the Varrable Sheet to see that TK has made the conversion 8 Go back to the Umt Sheet and de ne somemore conversrons cm to mm enter 1o CmAZto mmAZ enter 100 ft to In enter 12 RAZtoanZ enter 144 on K autom atrcauy calculates thrs fictox 9 Use the File Menu select Save Wandow md save the Umt Sheet to ame caued areaunrt Laterwe can merge thrs mformmon mto anothernnodelrnstead ofxetypmg rt 10 Swatch back to the Varrable Sheet and assooate hsts wrth each of the vanables Remember how to do thrsv Go to the Last Sheet The assooated hsts have the same chsplay and ca1cu1ahon umts as the vanables on the Varrable Sheet 11 Go back to the Varrable Sheet md change the chsplay umt for area to mm 2 TK does the conversron Now return rst Sheet and see that the hst rs sun In the ongmzl umts The umts are lmked only dunng creahon of the hst Any changes to erther the vanables or the hst s umts are done mdependently wwm 1115115 cam 50 12 Use the Appllcatlons Menu to access the TK lerary and select the Utllltles Sectlon Then select the Umts Sectlon and merge one ofthe Umt Sheets Into the current mo el I nlt Salve rm Wlndaws m S my Llhvaly A mules LlslManlDulalmn MadelSalvmg Mlscellaneaus Evavhlcsmlhlles s u w n 7 Aenspace Engmeeung 7 Ehemlslw and Ehemlcal Engmeeung D w Salemun IBM Add 39mm UNlTEDNVERSlDNS Unllsheelswllh canvevslans rm Vanna dlsclvhnes UK I saw mm W Summary 0 Your mltlal entry In the Unlt eld asslgns both the calc latlon and dlsplay unns to the varlable Subsequent entrles change only the dlsplay umt 0 Umts are not llke varlables They are Slmply text strlngs TK does not recognlze that lnAZ means mchessquare 0 Converslon factors work m both dlrectlons If m to cm 15 de ned then TK can also convert cm to In 0 Converslon factors can be Chamed Gwen m to cm and cm to mm TK knows In to mm There are no bulltrln unlt converslon factors You must de ne your own or merge m a Umt Sheet whlch was previously created See the TK lerary or Umts Import leard o Llsts can also have calculatlon and dlsplay umts Assoclated llStS lnltlally take on the dlsplay and Calculatlon unns of the varlables H waver su sequent changes OT llnked 0 Open the Vlew Propertles Dlalog to get a better mew ofthe umts for all vanables If you make an error when lnltlally entenng a unlt DO NOT type over the mlstake TK W111 lnterpret the lnltlal entry as the Calculatlon umquot and then attempt to convert to the second entry as the dlsplay umt Blank the eld usmg Edlt Cut or use the spacebar www ms uscmn JI TK Unit Wizards along wlth a hshng of malls You ust plck me one you wmt md TK updntes nae Vanable Sheet Rumor has lt Lhnt TKG wlll make ths wlznxd obsolete The Global Umts Summnxy wlzaed allows for globnl Niltchmg of umts throughout nae Vanable Sheet You can dame mall groupmgs such as us md Memo md Nmp between them 42111 Seleel a nun yne Select om Vlscasny wwm 1115115 cam 32 Review Exercise Enter the following equations on the Rule Sheet loan price 7 down X loanrl71r A7n pk X1r07n7k71r07n7k 1r ik X 7 pk T Xn Ti T 7 loan You may recognize these formulas as those used for evaluating consumer loans Here the variable sheet after reorganizing and the addition of comments VAR T ART F SHEET St Input Name Output Unit Comment price Price down Down payment loan Loan amount r Interest rate X Monthly payment n Number of monthly payment T Total of all payments Ti Total interest paid k Payment to be studied pk Principal paid in kth payment ik Interest paid in kth payment In this example units play an important role As implied by the equations the variable r is being calculated as the montbb interest rate in dm39malfom Unfortunately we don39t usually think in these terms Instead we talk about annual rates in percents Enter monthly as the unit for the variable r Go to the Unit Sheet and add the following conversion monthly to 0oyr enter 1200 for the conversion factor Go back to the Variable Sheet and change the display unit for r to 0oyr Let39s try it out on a few sample problems Given price 24000 down 6000 r 10 oyr n 48 this is the term of the loan in months k 1 this is the current month number WWW lltS as com 33 1 What is the monthly payment and total interest on this loan 2 The buyer can only afford payments of425 per month What interest rate would make this possible What change does this make in the total cost of the loan b0 The buyer negotiates the deal at 9 interest What monthly payment did they settle for List solve and set up a table showing the principal and interest paid in each of the 48 payments Show these curves on both a line chart and a bar chart Try the stacked bar option Save the file with the name Loan Formats Numeric Formats are TK objects just like lists and tables Formats can be assigned to Variables or lists or columns in tables A format can be assigned as the Global Format in the Options menu This format will then be assigned to all Variables lists and tables unless another format is speci cally designated for those objects For practice create a format and assign it to a Variable Comments Comments are also TK objects Comments have several unique features They can be linked by using an asterisk within a comment For example if a comment includes the teXt uts you can navigate directly from the current comment to the uts comment using a righticlick Comments on the List Sheet have a dual role in that they are used as the plot legend teXt for those lists We suggest that before you save a TK model create a comment displaying the author date and some description of what the model does The neXt time the model is opened the comment will be a nice summary WWW lltS as com 34 Mntthnk The MmhLank VW n m battam with TK sateen mmch lmms mmem m at nchan imam 3 hughhghted m m Euqu shm Ywu can ughtrchck m m MmhLaak Vxewta capy m equmanta PM m mathexpmgmm TK Salve aha mm a Mmhlaak Shut um 51mm mn hple mks md cm mm mm 3 P13 2 TE use m a mpa meet me insz a mum m canvemng famuhs and ca echng gxzpl39ncs pnaxta capymg may ng ppm Rzpnn thing Thu m m Wm yau cmuke m pmducmg 125mm bmed anTK madds 1 Capy mapm m Wm at Excel 2 Useadfle TK RzpanWmex Fde 702m Regan opum his sevem ndvmzzges Yau have camglete annual avewhn guns m m Pm nulammcn y uyam when yvu make charng m m mmm Yau can met me Whamex yauhke opum m usedta mm these mung damnan 2 can be mate 2mm especu y xfyuu mm m mcludz mmy dn exem TK ab ms m m apart 1h tesulhng 129m cm be canvaxted m m m m um cmbe subsequzndy mm m Waxd m mmy af m gupmd able s am make u cleanly Lhmhgh m canvexsmnpmcess 3a yau may needta capy mapm Lhasa mmun y WW mum 5 Sample Exercise Create a TK Solver model using the following formulas volume 13 piO radiusAZ height radiusAZ heightAZ slantAZ surface piO radius slant tand theta2 radiusheight cc39 Assign units to each of the variables using in as the base unit of length and deg for the angle Merge in a unit sheet from the TK Library Input 20 for the volume and 3 for the radius and solve Use the List Solve Wizard to generate a table and plot of surface vs radius as the radius ranges from 1 to 5 in steps of 02 Assign formats to the columns of the table as well as the variables on the variable sheet Use the Optimizer to determine the radius resulting in the minimum surface value Copy the equations into MathLook Add a comment to the model organize the sheets and save the file as CONE Create a report using FileiCreate Report Copy the variable sheet and paste special linking as a TKW Document Object in Word Change the inputs in TK and solve Check to see that the variable sheet updated in Word Try the same process with the plot Sample 80 70 su rface 50 40 30 1 15 2 25 3 35 4 45 5 radius in W lltS as com 36 Linking TK Solver Models with Excel TK Solver models can be llnkad wlth Excel spreadsheets for several pmposes You can use Excel to bulld a custom mterfacereport for the TK model You can use Excel as a K models together be used as lnputs In others You can use TK Packager unth a Llnkad spreadsheet to create The prerequlsltes for llnlrlng are as follows The TKmodel le must be saved The model must be con gured wth apartlcular set of mputs and outputs You cannot hnk a model that has no lnputs or outputs The model must solve wthout the use of a guess on the yanable sheet Default rst programmed In TK and tnggered by daault rst guesses on yanable subsheets Ltllst solymg ls reqturedtheyarlable sheet must mdudetheproper con gurahon The TK model must not lndude any of the tollowmg funcnons PROMPT QUERY MENU All such data gathermg should be done In E The TK model may lndude the error trapplng funcnons ERRMSG DEBUG PAUSEMSG but theyunll be lgnored In Excel Any reporhng of messages should be programmed In the Excel lnterface The TK SolverrExcel Toolklt mstalls as an Excel Addrln under the Tools menu A set of For th5 exerclse p Wlth A1 as the achy ce we lck the Insert TK Model lcon from the toolbar The Toollnt prompts for the name ofthe le Usethe CONE model get em eel hem rust mm m 11 cam 57 We will load the cone model but before we do we con nn the con gurmon of the TK vanab e sheet asweunu need at as randy for lmkmg forusem Excel When at solves as expected we save at md at of these mput vanables they unu act hke consunts In the model You unit not be able to gethem from Excel In thts Exaosewewxll use an the hputs and outputs quotltth12 Exmltnnlk w ard an em em new W wwm 1115115 cam Chck Next to nccept Lhamputs md theh theoutputs quotltth12 neenuulk w ard g gnse ed AH eeet M up We em use W Because thts model is set up for hst solving the hhk unu solve for the vmzbles oh the vnmble sheet md also hst solve he h xt two forms allow you to lmk plots md tables Smce om mode has nplot we unu lmk it It is uh omht to note thht the tables md plots us not edxmblethhm Exc Kyou or how ohok Next to nccept the default lmks uhul you come to the form unth oputh mvolvmg umts comments md foz mnts wwm 1115115 cam In thls exemse we wlll lndude the umts from the TK model smce our model has no comments w ard rv lnsen unns name I lnsen cammem r Use m Vavmm Vm ampms ms maael lemmas a VDWS a 7 ealamns m vauv spveadshea all We seat has gust You ire stxohgly admsed to ayoad the use of the TK tozmats when llnkmg to Excel By nccepnng the formde values you axe m fect 105mg the acctuacy of the actual calculataohs Thls wlll have a senous ampact on all subsequent calculataohs mdudmg l ml m full preoslon of the TK calculataohs wlll be mtamed For thls heasoh the Lmk Ylznxd defmlts to no for the use ofTK foxmnmng These yanables axe how cluectly lmked mm the TK Stallax model Try chmgmg the mdlus value from 3 to 4 md watch the outputs update The Value column of the output yanables contams tozmulas that lmk to TK Haze ls the n a m If you type over these tozmulas the Llnk ls destxoyed wwm 1115115 cam 40 The um calumn pmwdes a 13m af avnlhble un s m nah vmnble H39qu and mm Thzse m the un s nm m m Um Sheet m m chmedta the c m mm um m nah vmnble Yau cm mfzmnce Lhasa mm cells am ache lmulm m Em Ifyuu mzend m dn 3a yau shauld NOTmclude ms um canvexsmn am when yau m m mmm Yam Excel fammhs w nut updm mLhe pmpexun s mm TK vmnble un s m chmged Hexe39s astray zxnmgle Supp yau ma 1 lmuhm End 5 mum the mass with db n mman af can Yam famuhumul m Wlumz Assuming yau have med MmhLank faxExcelta yau39te yam at yuux 51mman appenxsam hmg mi Wlumzquotdensxty nwu 13k TK m suntah m Wm um amn f m m m mu w decxene by 1 mm mm Then m mm mm w m deems by m 31m naxwhmh umuld be can mg 1h TK cells m mmnmn um mtegnty but m new mg lmmlm yau mzy ma da nut Ifyau mm m um and um chmge yauxmnd me yau cm lack Lhzm up gm m Excelusmg m ExcelTaallm Lankmg 0pm cm m Lm Lnnk manta m m mdxm mdsur ce lms mmm CONE madzl Wm m fawn zppem nut m m was in mpufs md autpms panama m m mug eld 5 2 mus 1m and End mpmmgc mm ce lacmanwhete m mus 1m un begm Yau cm chck a ch m the Swamiquot md Em w an the lm places 5 the autpul m sur ng Then dunk the ox bumm n the ba fawn md the has w Pym m yuu Regen the mm with 13 m Chmge the vine with Wm m the spundsheet md mmh m sur ng 1m Pam Save the symmheez um alas n and 12mm on m Salve md F11 Nevta mm m WW mum Review Exercise This sample involves water flowing though a tube The resulting math model will compute the pressure drop due to friction as the water flows through the tube We will add unit conversions a table a plot and then link it to Excel Here are the equations to be used starting with the fluid property functions Here is the resulting variable sheet with comments and units and sample inputs A default first guess of 001 works well for the friction factor f Do you undersmnd why a guess is required to solve for f Use the Units lmport Wizard to load up the Unit Sheet WWW lltS as com 42 Use the List Solve Wizard to create a table and plot ofD and delmp as D goes from 01 to 05 Change the plot scaling to Yilog 10000 3000 1000 300 100 30 1 de ap beu xwo vmue Un Connnent 6236407361 0 0000753331 lbft s Fluid viscosity uid temperature Inside pipe diameter Pipe roughness 6236407361 lbs Weight rate of flow Pipe length 3183098862 fts Linear velocity Volumetric rate of flow 5270218965 Reynolds number 0007126549 Friction factor 2799580516 lbfftquot2 Pressure drop 1399790258 lbfftquot3 Pressure drop gradient WWWlltSllSCOm 43 Here 1 the table after lmkmg to Excel You can also lmk the hsts mteractwely y 1 mm 2u521252555 2 3 5951555 Lxsts are a speclzl type of oblect The most Important twt 1 that that length can Vary Because of thxs them locatxon m Excel must be handled more carefully The rst step 1 to 1dent1fy whlch hsts to lmk as mputs Input us IOutput list Name 4 gt I shuw Selected Items omy Ugt Range sheeumamza Apply Renae Remove Llst Link Cunent Madal Dfpe uw tu exeltkw v 0K Canca WWW ms as com 44 for you 2 screen A Hm llnkmg you cm cut md phste them to i new loc llon For exmlple it s probably best to store the hsts to the nght of the vnnzbles md plots Thnt my you cm tommt the column wldths wlthout nffecung the other llnked oblects You cm test the llst llnks the sme my you tested the vmzbles Thy chmgmg the second llsts you HE llhlahg 1 lot more cells to TK so you cm expect the solutloh eep thls m mlhd is you d 1b ey HE solut y sq ed mg for my vnnnble so Lhnt wlll pexfoxm When u Llnk process to sl w uu m sol blt K llnk long hsts mless th Solvexwlll xepeztedly updnte the ehtue llst slower lflong llsts ire Llnked n5 nzazleem wwm 1115115 cam Now that you have these lists in Excel you can format them as you like You can also use the Excel graphing capability as an alternative to those in the TK Solver model Click the Insert menu and select Chart to start the process Pressure Drop 10000 1000 100 deltap Linking Several TK Models With Excel You may link more than one TK model to a single Excel spreadsheet In fact this is an excellent way to do process modeling The results from one model can be used as the inputs for another with everything linked and communicating within Excel You can also link a single model two or more times to view as multiple cases for comparison To link a second model just position the cursor in a cell with room for your incoming variables and then launch the wizard by clicking on the Insert TK Model icon Test this with a simple TK Solver model with a single equation such as ab c Link it twice in a single spreadsheet Reference the output from the rst link in a formula for one of the inputs to the second link Here s an exaInple Input Value Output Value Value Output Value 46 WWWlltSllSCOm The underlylng Tllt model has the equatlon ao c wlth mputs for a and b and an output for c Alter llnklng the model twlce we edlted the yanable names m Excel and added a formula llnklng the output for c1 to the Input for a2 f32 where f3 ls the cell Contalnlng the output for cl The shadlng ls added for lllustratlon only Obylously lfyou haye formulas thls slmple you can easlly put them Into a slngle Tllt Solyer model Howeyer the process works the same regardless ofthe complexlty of the underlylng Tllt models Functions TK Functlons can be classlfled as elther bulltrln or userrde ned Listings of Available Builtin Functions There are seyeral ways to access llstlngs of TK s bulltrln functlons e the Help utlhty the leards tab ofthe Navlgatlon Bar and the CTRLF or CTRLrSPACE hot keys whlle edltlng equatlons Reset TH and open the Help utlllty to the Table of Contents open the Functlons and leards sectlon and then select Bulltrln Functlons All the categorles are dlsplayed Cllck on any group for further descrlptlons Close the Help wmdow when you are nlshed browslnglt 3 smells l lynx l swell mules Contents Specmc lnslluclluns lulllenuenlly lenulled acuuns Rele Inlon lellalluns cundllluns cumpallsun ul allemallves allowed by T Technical Suppon www ms 115com 47 2 luck on the Winds ub at the bottom of the N vlgnllon Bu md then select chuon m thts tmmmg semen When you re hushed bxowsmg thts 1x51 dick the Sheets tab wwm 1115115 cam 45 3 Begln typlng quoty n on the tule sheet and then press ctxlrf or ctxlrspace and you Wlll get an alphabetleal llstlng of all the bulltrln functhn ote that those functlons that start wlth speelal characters ate at the top ofthe llst KVISCEISITY en you select a functhn from the llst TK automatleally enters lt and dlsplays a tool tlp wlth a llstlng of the xequlxed value types You Wlll leam mete about value types later For now press Escape to clear the mle w my 115 com 49 TK Function Vocabulary The words in italics below have special meanings with respect to TK N b0 gt Ln 0 9 Enter the equation y LogX The variaale X is the argument of the function and the variable y is the rexull Because Log is an z39uvem39ale function TK s Direct Solver can solve for y given X or to solve for X given y Log is a auz39ltiz39u function which means that it is always available whenever we are working in TK Switch to the Variable Sheet and enter 7 a uumerz39e value as the input for X and solve The log function requires a numeric value as its argument and it returns a numeric value as its result TK variables can also have ymaolz39e values Enter the word red as the input for X Note that TK automatically places an apostrophe in front of the word Without the apostrophe the eXpression would look just like a variable so the apostrophe is TK s way of differentiating between variable names and symbolic values Symbolic values are sometimes called string or string values Symbolic values start with an apostrophe if there is just one word or are surrounded by double quotes if there are multiple words Solve again TK reports an error quotInvalid Symbolic Computationquot The log function cannot process a symbolic value Cursor down and enter red as the name of a third variable Enter 10 as its input value Now enter red as the input value ofX again TK replaces the word red with the value of the variable named red The rule y LogX includes a fumtz39ou re reme Functions can also be ealleel Switch to the Rule Sheet and enter the rule call logXy on the second line The semicolon separates the argument variable from the result variable Function calls have the same effect as function references but they allow for 0 to 20 result variables whereas function references can only have 1 or 2 result variables We will see the importance of function calls later Solve to verify that the second rule is OK Click File New to reset the sheets and then enter the rule y sumX Sum is also a built in function The function sum returns the sum ofa list of numeric values The argument variable X must have a symbolic value which refers to the name ofa list Go to the List Sheet and create a list called abc Open the subsheet for abc and enter the values 10 20 30 and 40 Go to the Variable Sheet and enter abc as the value for X TK converts it to the symbolic value abc Solve F9 to see the result Note that even though the rule processed a list of values List Solving was not necessary Remember that List Solving is the repeated process of rules on the rule sheet using lists ofvalues associated with one or more inputs In this eXample we only need TK to process the rule sheet one t1me WWW lltS as com 50 Function Wizards The wlzetds tab of the Namgmun Be presa39nx a campiete mllemun ufwlzards in help h h F m There a r d rH L l L vr Once you have evexyrhing entered ehek the Build Rule buttun and TK shows you what the expression mll look like m TK At that port you on ether ehek OK to paste the expression mto the current eld m TK ox copy cTRLc and paste CTRLV the expression wherever you need lt thk 23 l Integrals r Lwo mnmal r mmolmmml r 25 m 1 lillm I T i39 Furlwon Evilawn Helm l a G Slain r 2mm Rule Functions you should eonsldex the use of Rule Funmuns Once created Rule Funmuns can be saved and mexged mto othex appkcahuns as needed Rule funmuns can referenced repeatedly within other rules Go to the Engmeeong Examples seouon and study the clxoultDeslgh model The funmuns sex and par really sumpth the xule sheet farting model Wm HE us cam 51 Practice Problem TK Solver includes builtiin functions for converting between rectangular and polar coordinates The following example uses a rule function to extend this concept to allow for conversions to spherical coordinates 1 N b0 gt Ln Go to the Function Sheet and enter stord short for spherical to rectangular as the name of the function Cursor to the Type column and enter R to define stord as a rule function then open the subsheet and enter the equations x237 Pt01 dl theta zr ptordrhophi The quotdquot suffix after the trig functions indicates that the calculation is done in degrees The ptord function is a builtiin function for converting between polar and rectangular coordinates with angles measured in degrees Enter rhophithem in the Argument Variables field Enter xyz in the Result Variables field This maps the local variables with whatever expressions are used in referencing this rule function Activate the Rule Sheet and enter the following rule call stordrhophithetax1x0y1y0z120 The variables and expressions in this rule are mapped to the local variables in the stord function according to their position Those variables preceding the semicolon are mapped by position to the three Argument Variables in the function Similarly the three Result Variables in the function are mapped to the three expressions in the rule For example the expression x17x0 is mapped to the local variable x Enter the following inputs on the variable sheet and solve rhozlg thetaZ110 phiZZG x05 y07 201 The stord function solves for the local variables x y and z and then TK computes x1 yl and 21 on the Rule Sheetjust like a builtiin function Go to the Rule Sheet and highlight the rule Press CTRLiD and TK opens the stord function subsheet Another way to quickly access a useridefined function is via the functions icon fx on the Object Bar Once in the subsheet use the Commands menu and select Examine or click the ExaInine icon it looks like a magnifying glass to invoke the Examine Command WWW lltS as com 52 The Examine Command is used to evaluate an expression from anywhere in a TK model It is especially useful for debugging functions by evaluating local variables You can use it to check values call functions etc Examine the value of the local variable r That variable represents the projection of the distance rho onto the xy plane Use the File Menu to Save the Window to a file called stordfun The other sheets are not saved The stord function might be useful in other models in the future and we will be able to merge it and use it as we would a builtiin function 0 Procedure Functions Procedure functions procedures supplement TK s ruleibased capabilities with sequential programming and processing Procedures are called as subroutines from the rule sheet or from other functions Procedures cannot call rules from the rule sheet Procedures can not call on the Direct or Iterative Solvers to solve equations however those solvers CAN repeatedly process procedures during an iterative process Here is a complete listing of all the types of statements you can use in procedures An ASSIGNMENT statement has the form Variablename 2 expression or listelement 2 expression or namel nameZ 2 expression resulting in a pair of Values where narnel and narneZ can be names ofvariables or list element identifiers or one of each For example XYZi represents the ith element of the list XYZ Assignment smtements allow either or for the assignment operator You may also call functions in procedure statements A GOTO smtement has the form goto labelname A LABEL statement has the form labelname A RETURN statement has the form return A FORiNEXT loop construct has the form FOR Varname I expressionl TO expressionZ STEP expression3 statements NEXT Varname where expressionl and expression2 must evaluate to numeric values and the optional expression3 must evaluate to a nonizero numeric value defaults to 1 The optional statements inside the loop can include other correctly nested forinext loops WWW lltS as com 53 A CONTINUE statement has the form CONTINUE Variablename and takes control to the NEXT statement of the current loop or to the NEXT statement ofa loop at a higher level specified by the optional variablenaIne An EXIT statement has the form EXIT Variablename and takes control to the statement after the NEXT smternent of the current loop or to the statement after the NEXT statement ofa loop at a higher level specified by the optional variablenarne Practice Problem 1 Reset all the sheets and open the Function Sheet We will create a function which computes a factorial Activate the Function Sheet and create a Procedure Function named fact 2 Open the subsheet for fact and enter the information as shown below PROCEDURE FUNCTION fact Comment Computes factorials Parameter Variables Input Variables n Output Variables Z S Statement Z 1 If ORnOnl then return for i 2 to n Z iz next i The Comment field helps us identify the contents of the function There is one Input Variable and one Output Variable These work in a similar fashion as Argument and Result Variables in Rule Functions We use them to map values of local variables to the rest of the model 3 Go to the Rule Sheet and enter c factX The two variables in this rule are mapped to the variables in the function 7 X is mapped to n and c is mapped to z 4 Go to the Variable Sheet and enter 13 as the input for X and solve Change X to 20 and solve again 5 Enter an input value of 172 for X and solve again An error Open the fact subsheet and insert the following line in the first row to trap the error and provide a more helpful error message if ngtl70 then call errrnsg Function fact is not valid for ngtl70 0 Suppose you also need the procedure to generate a list called facts of the factorials up to and including the nth Insert the following as the first statement in the procedure Call blank facts WWW lltS as com 54 9 0 This will clear the facts list of any Values from a previous run Then insert the following statement just below the line 2 1 to place a 1 in the first element of the facts list facts 1 I 1 Then insert the following smtement just below the z zi statement facts I z This places the current Value ofz into the ith element of the facts list Suppose you would like to use different lists to store the factorials on different runs You can make the list name a Variable by removing the apostrophe in each of the three statements it is used For eXaInple factsi becomes factsi Then add facts to the list ofinput Variables in the function nfacts This tells the function that the Value of the Variable facts will be passed into the function The name of the list will be an input to the function The procedure will then place the Values into that list Edit the rule on the rule sheet adding a second input variable 0 I factxfacts Switch to the Variable sheet and enter the name of the list you would like to use to store the factorials When you solve F9 TK generates the list on the list sheet Change the inputs X and facts and solve again A new Value ofc is displayed on the Variable sheet and a new list is generated on the list sheet The TK Solver Library contains hundreds of procedures in Various groupings The Library conmins both Tools and Examples The eXaInples show the tools in action You can merge the tools into your own TK applications For example there is a file in the Statistics section of the TK Library that computes factorials combinations permumtions and arrangements for inputs of any size The functions in that model utilize special arbitrary length integer calculation algorithms and represent large numbers as multiple list elements WWW lltS as com 55 List Functions List Functions allows us to create lookiup tables with or without interpolation List functions relate the elements of two lists The mapping options are Table Step Linear and Cubic with the last two providing interpolation 1 Start with a fresh set of TK Sheets Go to the Function Sheet and create a List Function named f Open the subsheet List Functions require two lists of values and a mapping option If the lists were previously de ned in the TK model the values will automatically appear within the function 2 Enter color as the name ofthe Domain List and code as the name of the Range List LIST FUNCTION f Comment Domain List color Mapping Table Range List code Element Domain Range 1 red 100 2 white 200 3 blue 300 3 Enter the values red white blue in the Domain column and 100 200 300 in the Range column 4 Test the function using the EXaInine Command with the expression belue TK should return the value 300 Close the EXaInine form 5 Go to the Rule Sheet and enter the rule y fX The argument of the function X is mapped to the Domain and the result y is mapped to the Range Switch to the Variable Sheet and enter 200 as the input for y TK solves for X as the value 39white 6 Open the function subsheet Change the mapping option to Linear Change the values in the color column to 12345 Then change the values in the Range column to 2472387 TK will now interpolate within the given values 7 Go to the Variable Sheet and enter 325 for X blank y and solve TK interpolates between 7 and 23 in the range list and provides the answer Go back to the function subsheet change the mapping option to Cubic and solve again 8 Go to the Plot Sheet and create a line chart called f Open the subsheet and enter color as the XeAXiS List and code as the YeAXiS list twice W one with Lines and one with Curves When you plot F7 you can see the difference between linear and cubic interpolation WWW lltS as com 56 A Closer Look Passing Values to and from Functions We have already seen that Variables in equations can be mapped with local Variables in functions according to their position in the list of arguments and results for rule functions and inputs and outputs for procedure functions List functions always have one input mapped to the domain list and one output mapped to the range list Values can also be passed to and from functions directly Via list elements For example Place y1 temperature This equation places the Value of the Variable temperature into the 1St element of the list y That list element can be accessed from anywhere else in the TK model So a rule function might include the rule T ym List elements are accessible anywhere in TK and can be used to bypass the passing of Variables as function arguments Parameter Variables provide a means of passing Values directly from the Variable Sheet to a function This is useful for two reasons First since functions can call or reference other functions you may need an efficient means of getting a Value to a deeply nested function without having to pass the Value through each of the intermediate functions Second some functions assume that another function will have a specific number ofinputs as they process them Additional Values can be passed into the function using ParaIneter Variables Examples ofbuiltiin functions that reference other functions Numerical Integration INTEGRAL INTEGRAL2FIX INTEGRAL2VAR INTEGRAL3 FIX INTEGRAL3VAR Differential Equation Integrators OD ERK4 O DERK5Adapt OD EB S OD ESTI FFR OD ESTI FFB S ODERK5FINAL TK Library tools also reference other functions For example Various root finders repeatedly reference a function as they iterate to a solution The Optimization section of the Library includes tools which repeatedly reference functions until a max or min is found These tools pass inputs to the function but rely on paraIneter Variables for passing constants from the Variable Sheet throughout the process WWWutsusc0m 57 Review Problem Just as we can find the square root of a Variable or collate a list we can also use TK to process functions The TK Library has many tools for these tasks The most commonly used tools are in the areas of differentiation integration optimi ation and root finding For example we can differentiate a function with respect to its input Variable Likewise we can find the input to a function which leads to result of zero and so that input is a root of the function To further clarify note that we do not differentiate Variables or lists W we differentiate functions Given y fX we do not integrate y from 0 to 1 we integrate fX as X ranges from 0 to 1 With this in mind it is clear that we cannot integrate or differentiate a TK Variable we need to define a function and then process that For example suppose we have an equation such as y cosaxlcoshbx and we are interested in studying the relationship between X and y as a and b remain constant 0 Our first step is to enter the equation on TK s Rule Sheet along with sample inputs on the Variable Sheet Lefs use a 3 and b 075 X will Vary between 0 and 2piO We ll list solve and generate a plot St Input Name Output L y 76465998 1 x 3 a 75 b y cosaxcoshbx a 3 b 075 I 0 58 WWWlltSllSCOm Now let s study the slope of the funcnon at vanous values ofx To do thls we use the bulltrm dlfferentmtlon tool from the TK lemxy Select the tool called dlff13 from the Mathematlcs sedlon under 11an and merge lt mto the cment model PanmelevVaviahles Input Variables lumxh z Nmaun 39lun 7 name nnhe lunclinn tn di evenliale evalue nnhe dependenlvaviahle e increment l mle The procedure failures a slngle statement whlch evaluates the functlon at two pomts men the polnt of mterest and then dlvldes by the total lntemal 2 11 The value of h should be slamsly small sav 1E3 The bulltrm functlon APPLY ls the key to thls procedure APPLY allows the name of the be a vanable value APPLY sqn9 3 and APPLY lng10 1 9o lf we funcnon to ha fmx the value of the vanable funx exs to the name ofthe Tu Hrw d l ve an Expression APPLY process The easlest wav to do thls ls to copy the mle on th u cuon on the Fu ctlon Sheet Call at bnunce ob tlon e Rule sheet and crane a Rule n en pnsiethexule lnto the func the subsheet for bounce and y cnstz xjcnshth xj Enter ab for the anmetex Vanables x for the Argument Vanable and y for the Result Vanable Parameter Va ahles 2th Argumeanznzhles x n thrizhlvs y wwm 1115115 cam Hmmm Why are a and b listed as paraIneters and not arguments The answer is that we want to differentiate the function with respect to X while a and b remain constant The diffl3 procedure processes functions with one argument and one result ie y Since the bounce function includes 4 Variables two of them must be passed in directly from the Variable Sheet as paraIneters 0 Enter the reference to diffl3 on the Rule Sheet and solve Rule y cosaXcoshbx slope diffl3 bouncexlE 3 Input Name Output 76465998 1 X 3 a 75 b slope 03725461 So we see that the slope of the bounce function is 03725 at X 1 0 For a plot of the derivative change the status of slope to L and List Solve Then add slope to the list ofyiaXis list naInes in the current plot y cos3xcosh075x d dy 0 Lefs see if we can find the Value ofX at which the bounce function is minimized To do this set the slope Value to 0 and guess the Value ofX Input Name Output Y 7647552 X 994893071 3 a 75 b O slope Success By guessing near the appropriate spots indicated by the plot we could compute the locations of each of the local minimums and maximums in this fashion 60 WWWlltSllSCOm The TK Solvet Libtaty nlt Salve rm Wmdaws ample Applcelmns rmene 4 I l 4 I 4 Saleman I a 6 Add Eemave mnwetsel rechmcel Syslems lnc 2n2w Slele sneel Sulte mu Rackrmd ll sl l m 5 953 222 at my lament camel The TK lemryls accessedvta the Apphcahons Menu It ts a collectaoh ofTK flles Some of the flles contam a slngle usextdeflned tunctaoh Some contam lust umt convetstohs These slmple les ate generally classttaed as tools Some of the les contam complete examples t functaotts mexged together to solve a pamculat ptoblem such as tot cutvetatuttg These ate someumes tetetted to as apphcahons Tools ate mtehded to be merged mto yout models whlle Examples and Appllcahons ate mtehded to be used on thett own and ould cause confustot If mergedlnto anothet le Let s look at examples of each of the thtee types of Ltbtaty les www ms 115 com 51 Use the Library Menu to go to Utilities 7 List Manipulation 7 Tools and load the first tool there reverse A single function appears on the function sheet Name I ype Arguments IComment I reverse Procedure 10 Reversing the order of elementsin a list It is a procedure function processing a single input Open the subsheet to see the algorithm The procedure includes comments to help us understand its use We can see that it requires the name of the list to be reversed as the only input Create a small list on the list sheet and call the function to try it Lefs try another example Open the Library Menu again and go to Statistics 7 Distributions and Random Numbers and load the Normal selection Several functions appear on the function sheet Open the second one normCDF and observe the rules within WWWlltSllSCOm 62 There are four lines of comments and just a single equation We see that the function requires three inputs and returns one output Enter a rule on the rule sheet to reference this function and try solving it with some saInple values Alternatively you can use TK s Examine Command to process the function without entering a rule Try that too Next we ll look at some exaInples from the Library Open the Library Menu and go to Mathematics 7 Roots of Equations 7 Examples and select Polynomial Equations When the exaInple loads we see a rule sheet with comments and a single function call along with a mble in the lower portion of the screen with sample coefficients for a 10th order polynomial The Bairstow function could be loaded independently as a tool but this example shows it in action Solve and observe the updated mble with the ten roots of the polynomial Checking the Object Bar we see that there is also a plot of the solutions in the complex plane Roots of a Polynomial Equation in the Complex Plane 125 x 1 x 75 X 5 25 0 A A 25 5 75 X X 1 125 l 8 6 4 2 2 4 6 8 1 Imaginary Real Components WWW lltS as com 63 Many of the tools in the TK Library are illustrated by examples like this one For another exaInple use the Library Menu to go to Utilites 7 Graphics Utilities 7 Examples and select General purpose graphics When the file loads we see a Comment Sheet describing how to use the functions tools featured in the ExaInple Solve the model and View the plots UTS trucks carrying TK Lefs check the function sheet to see all the tools in this example WWW lltS as com 64 Some of the functions are specific to the example and some are generic tools used for generating and processing data points Let s take a look at the rotate function The function requires five inputs as described by the comments The coordinates are assumed to be in two lists The function updates those lists Now lefs look at an application from the TK Library Go to Statistics 7 Curve Fitting and select Polynomial Regression The application loads with comments to help get you started There is also a table with sample data set up to solve for the best fitting 2nd order polynomial Solve and the table fills WWW lltS as com 65 There are also plots Here is the plot of the data with the polynomial curve Polynomial Regression Try changing to a 4th order polynomial and observe the changes WWWlltSllSCOm 66 BAE 200 Week 14 102508 VBA Visual Basic for Applications Dr Rod Huffman VBA underlies the entire Office package Every Office program can be extended or manipulated using VBA The easiest way to access the power of VBA is by recording a macro A macro is a series of commands that are invoked as a unit Suppose for example that the user needed to import data from an external file sort the data apply transformations to the data and generate a report The data always looked the same ie the same format and content and the manipulations and reports always looked the same And suppose that this had to be repeated several or even thousands of times Why do it all manually Office programs allow the user to quottape the procedure that is record keystrokes and mouse clicks that control the various processes needed That macro can then be given a name assigned to shortcut keys or a button etc to make it easy to run the entire set of commands as a unit To learn how to record and execute macros see the Help utility for any Office program Sometimes it is difficult or impossible to get the macro recorder to record exactly what you want You might like to have a macro that is more generic and flexible than what is recorded You can edit macros using the VB editor AltF11 The editor shows the VBA code that was recorded and allows the user to change it In fact you can write procedures directly in the editor and never use the macro recorder Procedures are complex commands that come in two main flavors subroutines and functions A recorded macro will be a subroutine Sub A subroutine behaves as though all of the commands were executed from the user interface keyboard and mouse It can do anything that you could do by entering the commands manually Functions on the other hand behave just like the builtin functions in Excel eg sin average stdev An Excel function is called as part of a formula in a cell and can only affect the contents of the calling cell Userdefined functions U DFs can be written to work just like the builtin functions but do special or complex tasks VBA has many standard functions but it does not have nearly all of the functions that are available in Excel VBA functions eg sin can be called directly new 4 sinradians The Excelspecific functions however require a special method Suppose you want to use the Average function Avg WorksheetFunctionAveragevector The quotWorksheetFunctionquot Qualifier tells VBA to look in Excel s function library VBA gets a lot more complicated than this but the idea here is just to show that with a little knowledge of VBA the power of Excel expands greatly BAE 200 Week 3 Lecture notes 9908 MATLAB Predef39med Functions and Programing Engineering Analysis and MATLAB7 Chapters 6 and 8 Goals 1 Overview of prede ned functions available in MATLAB will not be able to cover all of them but can demonstrate a few and show students how to locate them in HELP They will reference this Chapter in later labs for some of these functions 2 Introduce the concept of programming inputoutput logic and family of if statements Notes Prede ned MATLAB Functions From Chapter 6 5 minutes MATLAB is programmed with a number of special characters A 39 etc commands ie clc clear help quit whos and functions ie sin plot median xlable These all work together to make MATLAB a powerful interface for number crunching and plotting giving it an advantage over highlevel programming languages due to the ease of programming It can execute more slowly that C or FORTRAN but it excels when dealing with matrix calculations You had some examples in the previous week on utilizing a few of these Time nor our patience will allow for us to go through every MATLAB function 0 Chapter 6 gives a good overview of the structure and application of I Elementary math Functions p 120 o absx sqrtx expx logx etc I Trigonometric Functions p 124 o sinx cosx tanx etc I Data Analysis Functions p 128132 137140 0 maxx minx meanx medianx etc o A summary of those discussed in Chapter 6 are found on p 157 for easy reference 0 Appendix 1 p 327334 provides a reference for Characters Commands and Functions 0 help command Help in Windows interface or wwwmathworkscom can direct you to more information as needed Activity 1 Type help in the command window 0 Notice all ofthe help topics that come on the screen You can choose these individual topics and nd functions you need or learn what they are for and how they work Clicking on or Help tab will give you the option of using indexing or to see MATLAB examples etc Try this We will be referring to these Functions with examples for the rest of the MATLAB lectures and laboratories Programming in MATLAB Up until now we have been using MATLAB mostly as a calculator in the Command Window Now lets expand our use of MATLAB to include programming techniques and the Edit Window MATLAB Inputs and Outputs p 208215 10 minutes 0 MATLAB allows the user to control how data is input into programs and how output is displayed 0 input command allows the programmer to request input I syntax for input of a scalar Activity 2 0wv input Enter a value for the velocity of the stream in ms The user will enter a value say of2 MATLAB will display owiv 2 will suppress output if you desire Note space given after ms to allow for user to input Not needed but looks better I Syntax for vector one row matrix or matrix the same but the user needs to be prompted to enter the data in correctly with and if necessary 0 MATLAB Outputs solutions as scalars matrices tables and plots Outputs can be formatted to become personalized or unique with output statement string ie The results of the simulation give out ow equal to I Display function dispx Can be used to display a string ie text or a variable anytime Most likely it will be used to display results of a program solution I Formatted Output fprintf Syntax fprintf format string variable1 variable2 Can be used to display tables they way that you want 0 Syntax fprintf f0rmat string table1 Need to include a width eldprecision eld to display the number in the format you desire o 42f I displays the minimum width allowed for the number of characters to be printed in this case 4 I precision eld is preceded by a period Gives the max number of decimal points 2 in this case Activity3 For syntax for all elements included SEE degree to radian example Set Current directory and access MBRadDegEX674m User De ned Functions created in the editor and stored as M les p 215222 10 minutes 0 O A function whether it is in MATLAB or created by the user is simply a piece of computer code that accepts an input argument from the user and provides output to the program MATLAB has many functions keeping us from have to program an approximation to an in nite series to nd the value of a function like sin We give it the input an angle and MATLAB calls and runs the function behind the scenes and returns the answer Many times we need to create our own functions with one or more dependant variables inputs So unless we want to program the equation in every time we can create a function in the editor which is saved as a script M File that can be called up by a program Activity4 open DRm in your editor I Notice the Syntax of the function 0 function outputiname functioniname inputs 0 outputiname is a variable or matrix can name it anything 0 Functioniname the name of the function The le is saved in your current directory as functi0nnamem 0 inputs input argument 0 The comment that I added under the function line will appear if you type help functi0nname help DR in the command window to describe what the function does I Open MBRadDegEX64m 0 Look where function is called 0 On line 6 notice the statement radians DRdegrees o In DRm output DRx It does not matter what you name these in the function le I Run MBRadDegEX64m discuss output Statement level Control Structures 19 222 125 minutes Sections of Computer code can be categorized as 0 Sequences a list of command that are executed one after another I These are the types of programs from Lab 2 example MATLAB Functions Executed one after another Selection Structures allows programmer to execute one or more commands based on a certain criteria being true or false I The program selects a path to continue on based on a logical condition They often contain Relational or Logical operators 0 MATLAB Can execute different commands that may take the program on different paths based on logical conditions Selection structures 0 Relational or Logical operators before you can understand how the program uses selection structures must understand the relational and logical operators that MATLAB uses to make decisions on where the program will go to execute the next set of commands I Relational operators Table 4 p 223 less than lt less than or equal to lt greater than gt greater than or equal to gt equal to not equal to I Logical operators Table 5 p 224 and amp not or I Activity 5 Examples of the use of operators In the Command Window type in the following xl 39 Y Test the following relational operators ans 1 true ans0 false 0 xgty o xlty 0 y Test the following combination of relational and logical operators 0 xltyampx y o Xgtylxlty o xltyxgty I What if you are comparing 2 matrixes Every element is compared and if the condition is not satisfied for every comparison MATLAB sees the result as false I find unique command to MATLAB Best to use the find command rather than use relational or logical operators see p224 228 for more details o If elsea elseif p229 233 I Considered CONDTIONAL STATEMENTS I Work much better with scalars rather than matrices o A conditional statement is used to tell the program to execute the following set of commands only if a certain condition is met otherwise the program skips the group of commands and goes to the end The if group of conditional statements include if end if else end and if elseif else end I if end Here if the condition is met the program performs the set of commands within the loop otherwise it goes to the end of the program Matlab commands if conditional statement Matlab commands end For example let s say that all biological activity in an organic medium will stop if its moisture content falls below a threshold value say 1 Above that threshold value we can simulate the biological activity using some type of relationship Matlab commands shown inside loop if else end Here if the first condition is not met the program performs the second set of commands before exiting the loop Matlab commands if conditional statement lst group of Matlab commands else 2quotd group of Matlab commands end Expanding further on the example used in the ifend statement let s say that if the medium is excessively wet say gt50 moisture we have anaerobic low oxygen biological activity usually less efficient than aerobic activity If the medium is not excessively wet we have aerobic biological activity I if elseif else end This command gives us more exibility for evaluating a wider range of conditional statements than the above statements Matlab commands if conditional statement lst group of Matlab commands elseif 2quotd group of Matlab commands else 3rd group of Matlab commands end Here we can further expand the range of scenarios regarding biological activity in the medium based on a wide range of moisture conditions If the medium is saturated we can shut down biological activity If the medium is excessively wet but not saturated we can simulate anaerobic activity If the medium is optimally wet we can simulate biological activity using efficient microbes say bacteria If the medium is somewhat dry we can simulate biological activity using lessefficient microbes say fungi If the medium is below threshold moisture content we can shut down biological activity We can use multiple elseif inside the above conditional statement The last condition is usually else but not always BAE 200 Week 9 Lecture and Activities as adopted from Joines et al 102108 Using Excel Functions and Equations Readings Functions and Equations Engineering with Excel Chapter 4 Naming cells 7 Chapter I p 2628 In this lab you will learn to 0 Find and use the builtin Excel functions 0 Giving data in cells names rather than cell location to improve equation writing 0 Write Excel formulas using 0 Mathematical operators and functions 0 Concatenation operator 0 Relational operators 0 Logical functions 0 IF functions Download Copy the files from the BAE 200 Week 9 Schedule InClass09xlsx onto your laptop for class activities Part 1 Using Excel Functions Careful use of Excel functions can make computerbased modeling much easier Excel Functions You may have already incorporated Excel functions like AVE RAGE and SUM in our earlier work Actually there are over 340 Excel functions and more specialized ones can be purchased through third party suppliers It is unnecessary to learn them all so we need to learn how to find the ones that we want to use The Formula tab in Excel contains many of these functions in the Function Library Section The categories for the builtin Excel functions are the following Financial Lookup amp Reference Information Date amp Time Database Engineering Math amp Trig Text Cube Statistical Logical The Function Library on the Formula Tab contains buttons to access most of these categories Note that the More Functions button includes the statistical engineering information and cube functions The Recently Used button provides easy reuse of functions that you have been employing in your worksheets The Insert Function Wizard 5 gives easy access to all of the Excel functions It contains a Search for a Function box that allows you to find relevant functions by entering search terms It also shows a dropdown list of the function categories listed above which includes the following additional categories All User Defined The All option is a comprehensive list of all available functions and is useful for searching if you know the name of the function or an approximate name User Defined is used when writing VBA functions Open Excel Click on the Formula gtInsert Function button Note the Search for a function39 and the help on this function Question I 39 Using the Search and Help features determine the category for each of the following builtin Excel functions NPV Pl FACT MAX IF SLOPE It is important to know what a function does You can get that information from the Insert Function dialog and its help on this function Page 2 Question 2 Consider the SLOPE function What does it do What are its parameters Using help on this function how is it calculated show mathematical formula Scroll to See Also can you get the intercept in Excel How Part 2 Writing Excel Formulas When writing formulas in Excel you can combine the values in multiple cells through the use of operators and functions We will use the following to illustrate Open InClass09xlsx Notice in the Logical worksheet that A10 has the value 134 B3 has the value 560 C6 has the formula B3 123 A2 has the value 10 D2 has the value text West B6 has the value text Ten Mathematical operators available include multiplication addition subtraction and exponentiation A You have seen their use previously When a formula is evaluated and parentheses are not used Excel resolves the formula according to the precedence table given in Table l Precedence for all operators is given at the end of these lecture notes in Table 2 Excel evaluates ties from lefttoright division Table 1 Excel Mathematical Operator Precedence Page 3 Question 3 Evaluate without using Excel the following Excel formulas Excel Formula Resulting Value 10 AlO A2 l342 23A2 Excel also has a concatenation operator amp that allows multiple pieces of text to be combined It has precedence level 4 in Table 2 Question 4 Evaluate the following Excel Formula Resulting Value Hi amp There Hi There Answer amp A10 Cost is amp amp AlOA2 Some operators cause the value to be either TRUE or FALSE These include the relational operators Equal to Less than lt Greater than gt Less than or Equal to lt Greater than or Equal to gt and Not Equal to ltgt Their precedence is always 5 in Table 2 lowest precedence in any formula Again ties are evaluated lefttoright Question 5 Evaluate the following Excel Formula Resulting Value C6ltl5 D2 West l5 lt 102 To combine relational operations we use the logical functions refer to Formulas Function Library gtLogical Common logical functions are OR AND and NOT Their evaluation also yields either a value of TRUE or a value of FALSE Page 4 argument is false Now the Excel expression in any other cell and its value are without using Excel ORD2 North NOTA2 ltgt 10 I I I RORD2 North D2 West B3 gt 5 I I I RANDC6 gt A10 D2 lt B6 NOTC6 gt 15 I I A 1 values again refer to Formulase mctmh LibraryeLoglcaz 5 ck 2 valuehmme The vaIue a vetuvh it the Dndmnn is tme vaIulejaIse The vaIue a vetuvh it the Dndmnn is false Page 5 Excel Formula Rigging IE A2 10 OK Not OK OK IFNOTA2 lt 10 ok not ok not ok IFANDVALUE 10 10 B3 gt 250 A2AlO lO IFORA2lt20 ANDC6lt20A10lt20 D2B6 West Question 7 Determine the value of the following without using Excel IFA2 gt lOIFA2 10 EQ GTI I quotLTI IFORAlO ltgt A2B3 gt 5A6 twoI I quotyesI no IF ANDISTEXT D2 C6gtl5 NOT FALSE quotnoquot Excel provides additional assistance when writing formulas in the spreadsheet by displaying a dropdown list that contain the function names andor named ranges Table 2 Excel Operator Precedence including logical expressions amp lt gt i i Page 6 Detecting Mycotoxins in Agricultural Commodities MYCOtOXInS Thomas B Whitaker Chemical compound Andrew Slate Produced by fungi Agricultural Engineers US Department ongriculture 39 carcmogemc andor tox39c Agricultural Research Service BA E NCS U httplwrMMbaencsueduusdaIVAMNAmitaker1htm History Types of Mycotoxins A atoxins 39 Discovered 1960 Fumonisins Killed 1ooooo birds 39 hrat x39quot A Deoxynlvalenol Turkey X dIsease Patulin Zearalenone Carcinogenicity of Aflatoxin Tumor Dose Time ugkg mg month 30 u 8 u 12 100800 In 100 u 150 u 20 u ugkg in diet m my total Aflatoxi ns B1 B2 G1 G2 AserlYus fa vus gt V Fungi Mycdtoxin Hdst Environment Host Environment Grains Corn Wheat Peanuts Tree nuts Cottonseed Figs High Temperature 90F High Relative Humidity 90 High Moisture Host 25 mo Feed 100 Units Aflatoxin Mycotoxins Correlations 3 milk 39 Insects 1 egg 39 HotDry Weather muscle Weak Plant Immature Seed Contamination Location Field Dryer yes Storage Processor Manufacturer no Consumer Peanut Storage Units of Measure Concentration Mass mycotoxin I Mass product Grams mycotoxin I Grams corn 0000000001 g mycotoxin I 1 9 corn 1 ng mycotoxin I 1 9 corn 1 nglg 1 nglg 1 ppb Research Regulatory Manufacturers AgenCIes Control of Mycotoxins Farmers Processors Parts per Billion 1 nglg or1 ppb 1 ft I distance to moon 1 cm I 10000 km 1 second I 317 years Regulatory Limits 100 Countries A atoxin B1 B1 B2 G1 GZTotal Both B1 and Total Limits differ Countries No of Countries A atoxin Limit 20 T Add Process 8 B1 I15 T Ready to Eat 2 B1l4 T Australia 15 T Canada 15 T Egypt 20 T Maize 10 T peanuts Japan 10B1 Philippines 20 T Worldwide Regulations for Mycotoxins 2003 FAO Food amp Nutrition Paper 81 Lot PPB Sample ppb ppb 3 Regulatory Limit US Dept of Agriculture Aflatoxin Inspection Three 5 kg Peanut SamplesLot 0 0 100 ppb What is wrong 10x5 kg sample shelled peanuts Peanuts Mean188 1 2 1319 41 43 69 16x10kg Sample Results nglg Variability Among Test Results 0 Large Increases With Lot PPB More Test Results Below Lot PPB Rare Event 0 0 Lot ppb 10 Test Result Contamination rate 31oooo 003 Maximum Aflatoxin Cottonseed 5000000 PPB Peanut 1000000 PPB 400000 PPB Corn 4 10x5 kg sample shelled peanuts 00003 13194143 69 Describe Sample Distribution Importer A atoxin Concentration quot7 Sampling Statistics of Interest 0 Mean Median Standard Deviation Variance ent of Variation Range Sample Test Results BAE 200 Week 6 Lecture notes 93008 Introduction to TK Solver 40 Reference Material Introduction to TK Solver 7 Universal Technical Systems Inc PDF Online Topics 1 Test next week 7 No homework due neXt week Will discuss in Lab 2 What is TK Solver used for 3 Introduction to TK Solver Environment Notes We have spent the rst four weeks developing engineering problem solving methods building a foundation of programming concepts and developing your foundation of MATLAB skills Today we will introduce a software that is a powerful equation solver 7 TKXSolver TK Solver is a rulebased problem solving and mathematical modeling environment that combines equation solving units conversion tables lists and user de ned procedures Videos 20 30 minutes Video 1 Introduction to the interface 5 minutes Video 2 Units and conversions 6 minutes Video 3 Tables and plots 8 minutes Video 4 MathLook 2 minutes Video 5 Built in Functions 2 minutes focus on HELP Kmlver Lonaraimnwhs luvNana Wm w Wer WEE l 5 EM 5 2 mg a sins More on the interface 20 minutes navigation around the model TK Navigation Bar Recommend keep it in view at all times Where all of the information for your model is managed Tabs 0 Sheets sign indicates data held in that sheet 0 Applications 7 mainly addins 0 Wizards 7 programs written in Visual basic to save time and perform a variety of tasks Status bar Bottom of the sheet Left Lets you know what sheet you are on and where Right 7 Status on solving F9 or OK memory clock etc MathLook In navigation bar list Allows you to View equations in rules sheet cut and paste plots pictures data etc Need to cut and paste into this View A few TIPS Don t maximize windows 7 you lose interactivity Best to keep Rules Variables and Navigation Bar all up at same time Cascade windows good practice 1 piece of confusion for new users Cannot leave a sheet before nishing editing If the cursor is still blinking you need to hit ENTER to move away from that sheet or to some of the toolbars You must clear entries completely by using SPACE BAR then ENTER to remove a unit or input they call it blanking the entry Comments can be entered using In lab we will enter some equations in and let you see how this all works


Buy Material

Are you sure you want to buy this material for

25 Karma

Buy Material

BOOM! Enjoy Your Free Notes!

We've added these Notes to your profile, click here to view them now.


You're already Subscribed!

Looks like you've already subscribed to StudySoup, you won't need to purchase another subscription to get this material. To access this material simply click 'View Full Document'

Why people love StudySoup

Jim McGreen Ohio University

"Knowing I can count on the Elite Notetaker in my class allows me to focus on what the professor is saying instead of just scribbling notes the whole time and falling behind."

Kyle Maynard Purdue

"When you're taking detailed notes and trying to help everyone else out in the class, it really helps you learn and understand the I made $280 on my first study guide!"

Bentley McCaw University of Florida

"I was shooting for a perfect 4.0 GPA this semester. Having StudySoup as a study aid was critical to helping me achieve my goal...and I nailed it!"

Parker Thompson 500 Startups

"It's a great way for students to improve their educational experience and it seemed like a product that everybody wants, so all the people participating are winning."

Become an Elite Notetaker and start selling your notes online!

Refund Policy


All subscriptions to StudySoup are paid in full at the time of subscribing. To change your credit card information or to cancel your subscription, go to "Edit Settings". All credit card information will be available there. If you should decide to cancel your subscription, it will continue to be valid until the next payment period, as all payments for the current period were made in advance. For special circumstances, please email


StudySoup has more than 1 million course-specific study resources to help students study smarter. If you’re having trouble finding what you’re looking for, our customer support team can help you find what you need! Feel free to contact them here:

Recurring Subscriptions: If you have canceled your recurring subscription on the day of renewal and have not downloaded any documents, you may request a refund by submitting an email to

Satisfaction Guarantee: If you’re not satisfied with your subscription, you can contact us for further help. Contact must be made within 3 business days of your subscription purchase and your refund request will be subject for review.

Please Note: Refunds can never be provided more than 30 days after the initial purchase date regardless of your activity on the site.