” 辅导ENGG1811语言、python编程设计调试、 写作python程序ENGG1811 20T3 Assignment 2: Biofuel Production – Simulation and DesignLearning Objectives:1. Applying programming to solve a simple engineering design problem2. Writing a python program to simulate an engineering system3. Applying a number of python features, which include array, vectorisation, built-infunctions and others4. Applying good Software engineering practices, which includes proper documentation,program style.Aaron Quigley, October, 2020Deliverables: Submit by 17:00 on Friday of Week-10.Late Penalty: Late submissions will be penalised at the rate of 10% per day (includingweekends). The penalty applies to the maximum available mark. For example, if yousubmit 2 days late, maximum available marks is 80% of the assignment marks.Submissions will not be accepted after 9am Wednesday of Week-11. To Submit thisassignment, go to the Submission page and click the link named Make Submission.GENERAL RULES1. This assignment is weighted at 20%2. You are reminded that work submitted for assessment must be your own. Its OKto discuss approaches to solutions with other students, and to get general helpfrom tutors or others, but you must write the python code yourself. Increasinglysophisticated software is used to identify submissions that are unreasonablysimilar, and marks will be reduced or removed in such cases.3. The Student Code of Conduct sets out what the University expects from studentsas members of the UNSW community. As well as the learning, teaching andresearch environment, the University aims to provide an environment that enablesstudents to achieve their full potential and to provide an experience consistentwith the Universitys values and guiding principles. A condition of enrolment is thatstudents inform themselves of the Universitys rules and policies affecting them, conduct themselves accordingly. (see the course outline page with links).4. You should also read the following page which describes your rights andresponsibilities in the CSE context: Essential Advice for CSE StudentsEssentialThe University views plagiarism very seriously. UNSW and CSE treat plagiarism asacademic misconduct, Which means that it carries penalties as severe as beingexcluded from further study at UNSW. [see: UNSW Plagiarism Procedure]Resources Provided to youThere are a number of python files that you need to do this assignment. These files arein assign2.zip. We introduce these supplied files, see the section on Supplied Files.GroupsFor this assignment, you need to work in a group of two with the restriction that yourgroup partner must come from the same lab class (i.e. same lab time slot and labroom). If you want to work on your own, please check with your tutor.ENGG1811 20T3 Assignment 2: Biofuel Production – Simulation and DesignIntroductionIn these days, with the worlds attention turned to viruses, infection and diseasetransmission some people think that bacteria are harmful. In reality there are manydifferent types of bacteria in this world. Some bacteria are harmful to humans but somebacteria help us (e.g. curdling milk) or in our bodies (e.g. our digestion) help us to live.Have you ever considered the possibility that bacteria can also be factory workers?Engineers and scientists are working on using bacteria to produce certain chemicals andmaterials. An example is to use bacteria to produce fuel for us. In engineering, we oftenwant to optimise the Process, so we may want to make the bacteria to produce as muchfuel as possible in a given time. However, there are often constraints in nature. The truth isthat fuel is toxic to bacteria, so we need to find a way for the bacteria to make a lot of fuelbut at the same time keep them alive! This biofuel production process is the theme of thisassignment.The aim of this assignment is to give you an opportunity to work on a small-scaleengineering design problem in python. The engineering system that you will be working onis biofuel production. Your goal is to determine the design parameters so that the bacteriacan produce as much fuel as possible while respecting a couple of constraints. You willuse simulation as part of the design process.Assignment overviewThis assignment is design to imitate engineering design. You will see the followingelements:1. (Simulation) Simulation of a biofuel production system with different designparameters.2. (Design) Evaluate the performance of the systems that you have simulated.As noted on page 1, there are a number of files provided to get you started please see thesection on Supplied Files below for more details.We will first give an introduction To biofuel production. This introduction is meant to giveyou some intuition on the design problem. After that we will tell you what you need to dofor the assignment.Biofuel production processWe will give you a basic mental picture that you can use to visualise biofuel production. Apictorial representation of a bacterium is in Figure 1. A bacterium is a single-cell organism.It has a cell membrane, which you can think about as the skin of a bacterium. By usingbioengineering, we can get the bacteria to produce fuel for us. This production will takeplace within the bacteria, i.e. inside the cell membrane of the bacteria.Now that you know that fuel is produced inside the membrane of bacteria, the next thingyou need to know is that having the fuel staying inside the bacteria is neither good for usnor the bacteria. It is not good for us because we cannot collect the fuel. It is not good forthe bacteria because it is toxic to them. This means we need a way to get the fuel from theAaron Quigley, October, 2020ENGG1811 20T3 Assignment 2: Biofuel Production – Simulation and Designinside of the Membrane to the outside. A good news is that bacteria can make effluxpumps on the membrane to push the fuel from the inside of the membrane to the outside.With these efflux pumps, we can reduce the amount of fuel in the bacteria (i.e. toxicitylevel) and collect the fuel, solving the Problem that we talked about in the last paragraph,but there is one catch. Efflux pumps, though useful, can be a burden to the bacteria. Thismeans that a bacterium should not have too many efflux pumps. A clever way is to get thebacteria to make efflux pumps on demand. If a bacterium senses that there is a lot of fuelinside its membrane, it should Make more efflux pumps to expel the fuel; and vice versa.With the help of bioengineering, it is possible to have biosensors in bacteria to sense theamount of fuel in the bacteria.The above mental picture should give you the intuition you need for the biofuel productionprocess. In order to do engineering design, we need a mathematical model which we willdiscuss next.One mechanism for dealing with toxicity is to export the fuel molecules using effluxpumps. These pumps are Protein complexes in the cell membrane that recognize toxicsubstrates and expel them. Once a toxin is sensed, a channel in the membrane opens inan iris-like fashion and the toxin is pushed out using the electrochemical gradient acrossthe cell membrane. From, Dunlop, Mary J., Jay D. Keasling, and Aindrila Mukhopadhyay.A model for improving microbial biofuel production using a synthetic feedback loop.Systems and synthetic biology 4.2 (2010): 95-104.A mathematical model for the biofuel production processAaron Quigley, October, 2020Figure 1: (a) Biofuel production using microbes (e.g. bacteria) to convert sugar into fuel.(b) Efflux pumps can be used to export biofuel out of the cell (adapted from Dunlop 2010)ENGG1811 20T3 Assignment 2: Biofuel Production – Simulation and DesignFrom the biofuel production description that we have discussed above, you know that weare interested in a few quantities: the amount of biofuel inside the bacteria because this isrelated to the toxicity level; and, the amount of biofuel outside the bacteria because this isthe amount that we can collect. We would like to have a mathematical model which tells ushow these two quantities vary over time. The mathematical model can tell us how thefollowing five quantities vary over time: The amount of bacteria in the colony denoted by the mathematical symbol n. Notethat we scale the amount by the maximum possible of bacteria so n is a number inthe interval [0,1]. The biosensor output denoted by R which is a non-negative real number. The amount of efflux pumps, Denoted by p, which is a non-negative real number. The amount of biofuel in the interior of the bacteria, denoted by bi, which is a nonnegativereal number. We also call this internal biofuel. The amount of biofuel in the exterior of the bacteria, denoted by be, which is a nonnegativereal number. We also call this external biofuel.You will use simulation to determine these five quantities.There are two design parameters which we will vary, they are: The biofuel production rate b. (python variable name alpha_b) The efflux pump production rate p. (python variable name alpha_p)We have placed the mathematical model for the biofuel in the appendix 1. We believe it isbest for you to understand what you need to do for this assignment first before exploringthe mathematical model. You should be able to understand what you need to do for theassignment Without going into the mathematical model at this stage.The mathematical model (in Appendix 1) for biofuel production is based on Reference [1].Overview of tasksWe have divided the work into a number of tasks. Task 1 and Task 2: are on simulation Task 3: is on engineering designTask 1: Simulate the biofuel production system with a python functionThe aim of this task is to write a python function sim_biofuel (which should be in a filewith name sim_biofuel.py) to simulate the biofuel production process. You can find atemplate for this function in sim_biofuel_template.py (in assign2.zip). You shouldrename it as sim_biofuel.py before you start. The declaration of the functionsim_biofuel is:def sim_biofuel(data_set_to_use, time_array, init_bacteria_amount, alpha_b, alpha_p) :The above function returns five arrays. All these five arrays should have the same lengthas the input array arrayTime. These five arrays contain the following simulation outputsin this order of expected function output: bacteria_amount_array for the amount of bacteria nAaron Quigley, October, 2020ENGG1811 20T3 Assignment 2: Biofuel Production – Simulation and Design sensor_array for the biosensor output denoted by R pump_array for the amount of efflux pumps p biofuel_int_array for the amount of biofuel in the interior of the bacteria bi, biofuel_ext_array for the amount of biofuel in the exterior of the bacteria be,The inputs are: data_set_to_use is an integer indicating data set to use containing constantsyou need for simulation. time_array is a Array of time instances that you need for simulation. init_bacteria_amount is a scalar for the initial amount of bacteria in thecolony. alpha_b is a scalar for the design parameter for biofuel production rate b alpha_p is a scalar for the design parameter efflux pump production rate p The implementation of sim_biofuel requires the mathematical model for the biofuelproduction process. (The model is in Appendix 1 and the suggestion is that you read themodel later.)Hint: You can use the python simulation program para_ODE_ext_lib.py andpara_speed_height_by_ODE.py (code from Week 7s lecture) or the material from Lab08: Simulation and its applications as a starting point to develop the function sim_biofuel.The only non-zero initial condition is the amount of bacteria. This is defined by theconstant INITIAL_BACTERIA_AMOUNT, which is specified in the simulation data set. Thepython files provided for testing load this constant in for you, so you can assume thisconstant is available and use it. You can assume the initial conditions for R, p, bi and beare zero.The array time_array is a uniformly spaced array of time instances. The start and endtimes, as well as time increments, are specified in the simulation data set. The python filesprovided for testing your Function load these constants in for you, as well as define thearray time_array. So, you can assume the time array is available and use it.When you call the function sim_biofuel, the only inputs that you need to adjust are thevalues of alpha_b and alpha_p.For example, if you want to do simulation with b = 0.1 and p = 0.6, you should use:def sim_biofuel(data_set_to_use, time_array, INITIAL_BACTERIA_AMOUNT, 0.1, 0.6) :Note that you can leave the first three inputs (shown in red) as they are shown in theabove line. You may want to read through the file test_1.py to give you an example onhow to call the function.You can use the python program test_1.py (in assign2.zip) to test your sim_biofuel.The program test_1.py first reads in the constants and parameters for the selecteddata set. It then creates an equally spaced array time_array. The program then calls thefunction sim_biofuel to compute the five outputs of the simulation, and compares themto the reference values. If you see the error is small, i.e. less than 10-6, then yoursim_biofuel should be working correctly.Aaron Quigley, October, 2020ENGG1811 20T3 Assignment 2: Biofuel Production – Simulation and DesignNote that we have Provided two different sets of system and simulation parameters. Youcan choose between them by assigning the variable data_set_to_use to either 1 or 2.You can find this variable near the beginning of the file. For each system parameter set,you can use three different pairs of design parameters in test_1 to test yourdata_set_to_use. The selection is done by setting the variable test_index to 1, 2 or3.You can test this function by using the script test_1. If you adjust the value of thevariable test_index, you can choose between 3 different set of design parameters.Task 2: Generate the design objective and constraints for many pairs of (alpha_b,alpha_p)We have mentioned earlier that biofuel is toxic to the bacteria. It would be desirable if wecan choose our design parameters b and p to limit the maximum amount of biofuelinside the bacteria. This is one design constraint that we want to impose. For our design,we would like to find design parameters which limit the maximum amount of internalbiofuel. We want to do this quantitatively. Let us assume that you have done the simulationand have the Amount of internal fuel stored in the array biofuel_int_array. Themaximum amount of internal biofuel is then the maximum value in the array forbiofuel_int_array.You have seen that different values of b and p can lead to different behaviour of internalbiofuel level. In the same way, different values b and p can lead to different amount offuel that we can collect. Our design objective is to collect as much fuel as possible at theend of the production process. We can measure this design objective quantitatively byusing the value of the last element of the array biofuel_ext_array, which representsthe amount of external biofuel at the end time of the simulation.In this task, you will use many different pairs of (alpha_b, alpha_p) for simulation. Foreach pair of (alpha_b, alpha_p), you will simulate the biofuel production and use theoutput of the simulation to determine: (1) The amount of biofuel you can collect and (2)The maximum Amount of internal biofuel.The steps for this task are:1. Create an array of alpha_p_array of equally spaced p values. The first value isALPHA_P_LOWER and the last value is ALPHA_P_UPPER with an increment ofALPHA_P_STEP. These three constants are specified in a parameter set that theprogram test_2.py reads in. You can use them directly. Hint: Note that theprogram test_2.py has a line which creates an equally spaced arraytime_array. You can similarly create an array equally spaced alpha_p_arrayusing the above three values (lower, upper and step values).2. Create two zero arrays whose number of rows is the number of elementsin alpha_b_array and the number of columns is the number of elements inalpha_p_array. You should call these two arrays max_internal_biofueland final_external_biofuel.3. Perform simulations for all possible pairs of (alpha_b, alpha_p) wherealpha_b comes from the elements in alpha_b_array and alpha_p comes fromthe elements of alpha_p_array. For each pair of (alpha_b, alpha_p), weneed to do the following:Aaron Quigley, October, 2020ENGG1811 20T3 Assignment 2: Biofuel Production – Simulation and Design The (i,j) element of the array max_internal_biofuel, i.e.max_internal_biofuel(i,j), should be assigned the maximum amountof internal biofuel when alpha_b_array(i) and alpha_p_array(j)are used. For example, The (i,j) Element of the array final_external_biofuel, i.e.final_external_biofuel(i,j), should be assigned the amount ofbiofuel that can be collected when alpha_b_array(i) andalpha_p_array(j) are used. This array final_external_biofuelwill be similar to the above example for max_internal_biofuel.Hint: please read the examples in the file numpy_2d_examples.pyIn this part you need to implement the following function:def generate(data_set_to_use, time_array, INITIAL_BACTERIA_AMOUNT, alpha_b_array,ALPHA_P_LOWER, ALPHA_P_UPPER, ALPHA_P_STEP) :Input (7 values): data_set_to_use, time_array,INITIAL_BACTERIA_AMOUNT, alpha_b_array,ALPHA_P_LOWER, ALPHA_P_UPPER, ALPHA_P_STEPOutput (4 values): alpha_b_array, alpha_p_array,max_internal_biofuel, final_external_biofuelYou can use the file test_2.py to check whether you have calculated the two arraysmax_internal_biofuel and final_external_biofuel correctly.Task 3: Engineering designAaron Quigley, October, 2020ENGG1811 20T3 Assignment 2: Biofuel Production – Simulation and DesignThe engineering design problem is to choose good design parameters to meet our designrequirements. In our case, a design has two design parameters alpha_b andalpha_p. In Task 2, you have associated each design, or each pair of (alpha_b,alpha_p), with two quantitative measures: Amount of Biofuel that can be collected Maximum amount of internal biofuelWe want to choose the best pair of (alpha_b, alpha_p) based on these twoquantitative measures. We know that large amount of internal biofuel is undesirable. Whatwe want to do is to impose an upper limit on maximum amount of internal biofuel. Weintroduce the following threshold: THRESHOLD_MAX_INTERNAL_FUEL is a threshold on the maximum amount ofinternal biofuelThe above constant is specified in a parameter set that the program test_3.py reads in.We say that a design is acceptable if Maximum amount of internal biofuel is less than or equal toTHRESHOLD_MAX_INTERNAL_FUEL,Out of all the designs that are acceptable, we will choose the design that allows us tocollect the largest amount of biofuel. We will call this design the best design.For comparison purpose, we will also determine a poor design which we define as thedesign that maximises the amount of biofuel that can be collected, without considering theabove constraint.Once you have obtained the best design and the poor design, you need to return thesefour values from the following function you need to implement for his part.A requirement for Task 3 is that you should complete this task without using any loops.You can only get full marks if your solution does not use loops. If your solution requiresloops, then you can only get a reduced mark.Hint: You can easily implement this function WITHOUT using a loop structure. Please read(or re-read!) lecture notes and labs on numpy, and also the related code examples. Inparticular, look for numpy functions that may help you to solve problems related to Task-3.In this part, you need to implement the following function:def design( THRESHOLD_MAX_INTERNAL_FUEL,alpha_b_array, alpha_p_array,max_internal_biofuel, final_external_biofuel) :Output (return values): best_alpha_b, Best_alpha_p, poor_alpha_b, poor_alpha_pYou should be able to determine whether your answers are correct by manually checkingon the elements of the arrays. You can do that. The arrays are big so you may want tocome out with some smaller arrays yourselves to test your work. We strongly encourageyou to do that because it is always good to try to check your own work. When you go outto work, you will Need to check your own work. We have also placed the answers herebut we encourage you to check your own work before looking at them.Aaron Quigley, October, 2020ENGG1811 20T3 Assignment 2: Biofuel Production – Simulation and DesignRemark: We have used exhaustive search here to determine the design parameters. Thisis certainly not the most efficient algorithm but you will learn better optimization methods inlater years.StyleYou should make sure that all your files are properly documented with appropriatecomments. Variables that you use should have well chosen names and their meaningexplained. Appropriate style should be used.Supplied FilesThe supplied files are (in assign2.zip): The file sim_biofuel_template.py is for Task 1. You should rename it assim_biofuel.py The file generate_template.py is for Task 2. You should rename it asgenerate.py The file design_template.py is for Task 3. You should rename it as design.py We have two sets of parameters. You can choose between the two sets ofparameters by using the variables data_set_to_use. Each set of parameters ismade up of constants in two files:1. System Parameters which are the constants you need for the mathematicalmodel in biofuel_system_parameter_sets.py.2. Simulation and design parameters inbiofuel_simulation_design_parameter_sets.py. Files for testing1. test_1 for testing Tasks 1.2. test_2 for testing Tasks 2.3. test_3 for testing Tasks 3.4. These files require support files, which are set1_check.pickle andset2_check.pickle files.Aaron Quigley, October, 2020ENGG1811 20T3 Assignment 2: Biofuel Production – Simulation and DesignGetting Started1. Download the zip file assign2.zip, and unzip it2. Rename/move the directory (folder) you just created named assign2 to ass2. Thename is different to avoid possibly overwriting your work if you were to downloadthe assign2.zip file again later.3. First browse through all the files provided, and importantly read comments in thefiles.4. Do not try to implement Too much at once, just one function at a time and test that itis working before moving on.5. Start implementing the first function, properly test it using the given testing file, andonce you are happy, move on to the the second function, and so on.6. Please do not use print or input statements. We wont be able to assess yourprogram properly if you do. Remember, all the required values are part of theparameters, and your function needs to return the required answer. Do not printyour answers.TestingTest your functions Thoroughly before submission. You can use the provided pythonprograms to test your functions.Please note that the tests provided in these files cover only basic scenarios (cases), youneed to think about other possible cases, modify the files accordingly and test yourfunctions.SubmissionA complete submission Should contain the following three files (as described above):1. sim_biofuel.py2. generate.py3. design.pyThe submission system will accept the above three filenames. You must not submit anyother files.To Submit this assignment, go to the Submission page and click the tab named MakeSubmission.Assessment CriteriaWe will test your program thoroughly and objectively. This assignment will be marked outof 20 where 18 marks are for correctness and 2 marks are for style.CorrectnessThe 18 marks for correctness are awarded according to these criteria.Criteria Nominal marksTask 1 (Function sim_biofuel) 6Task 2 (Correct max_internal_biofuel andfinal_external_biofuel) 6Aaron Quigley, October, 2020ENGG1811 20T3 Assignment 2: Biofuel Production – Simulation and DesignStyleTwo (2) marks are awarded by your tutor for style and complexity of your solution. Thestyle Assessment includes the following, in no particular order: Use of meaningful variable names where applicable Use of sensible comments to explain what youre doing Use of docstring for documentation to identify purpose, author, date, data dictionary,parameters, return value(s) and program description at the top of the fileAssignment OriginalityYou are reminded that work submitted for assessment must be your own. Its OK todiscuss approaches to solutions with other students, and to get help from tutors andconsultants, but you must write the python code yourself. Sophisticated software is used toidentify submissions that are unreasonably similar, and marks will be reduced or removedin such cases.Further Information Use the forum to ask general questions about the assignment, but take specificones to Help Sessions. You can ask your tutor during your lab time any queries you may have regardingthis assignment. Keep an eye on the class webpage notice board for updates and responses.Task 3 (Correct values of alpha_b andalpha_p for the two designs). Reducedmaximum: 1.56Aaron Quigley, October, 2020ENGG1811 20T3 Assignment 2: Biofuel Production – Simulation and DesignAppendix 1Mathematical model for biofuelThe model consists of five ordinary differential equations:Some helpful intuition For some of these equations at the end of theappendix.Note that for the purpose of simulation, there are three groups ofquantities:1. Time dependent variables: n(t), p(t), R(t), bi(t) and be(t). These arequantities that you Want to use simulation to obtain.2. Two design parameters: b (python variable: alphaB) and p(python variable: alphaP). You will use different values of these twoparameters in Simulation to see how they change the amount of fuelproduced internally and externally. Note that alphaB and alphaPare two inputs to the simulation function that you need to write.3. The rest of the parameters (n, n etc.) are constants. A mappingbetween the mathematical symbols and their python constant namesis below. You will need to make use of these constants in your pythonsimulation Code. Essentially, you replace the mathematical symbolby its corresponding python name in your simulation code.Aaron Quigley, October, 2020ENGG1811 20T3 Assignment 2: Biofuel Production – Simulation and DesignThe next step is to apply Eulers forward method to the ordinarydifferential equations, which result in the following equations you need forsimulation.Mapping between symbol names and python constantnamesThe python constant names are in upper case. For most symbols, the firstpart is the name of the Greek alphabet, followed by an underscore and thenthe subscript. The values of these constants are defined in files with thename that contains the words BiofuelSystemParameterSet.Aaron Quigley, October, 2020ENGG1811 20T3 Assignment 2: Biofuel Production – Simulation and DesignMeaning behind the equationsRight-hand side (RHS) of (1) describes the rate of change in the amount ofbacteria. The First term is the logistic growth function taking into accountthe limitation of resources. You can learn more on logistic growth fromthis Wikipedia page ( httpss://en.wikipedia.org/wiki/Logistic_function ). Thesecond term is the death rate of bacteria due to biofuel. The third term isthe death rate due to efflux pumps.RHS of (3) is the Rate of change in the number of efflux pumps. The firstterm is a base production rate. The second term describes how biofuel inthe bacteria affects the production rate. Essentially, the more the biofuelinside the bacteria, the higher the production rate. The last term is thepump degradation rate.RHS of (4) is the rate of production of biofuel in the interior of bacteria.The first term says the production rate is proportional to the amount ofbacteria. The second term is the rate at which biofuel is pumped out of thebacteria by efflux pumps.RHS of (5) is the rate at which biofuel is pumped into the exterior.Aaron Quigley, October, 2020如有需要,请加QQ:99515681 或邮箱:99515681@qq.com
“
添加老师微信回复‘’官网 辅导‘’获取专业老师帮助,或点击联系老师1对1在线指导。