Hello, dear friend, you can consult us at any time if you have any questions, add WeChat: daixieit


CS0011 Introduction to Computing for Scientists Project 1 Lab 1


Overview

Consider the following problem:

You are docked at the ISS with your shuttle, the Knight, when you receive an alert that space pirates are attacking a currently unmanned base on Mars. Your intelligence crew reports that the base  is  reasonably  well-protected,  but  losses  will  nonetheless  result.  They  estimate  losses  of $120,000 per day (for this project, we will be considering only Earth days, 24 hours), until you can reach the base and prevent any further damages. Luckily, Earth and Mars are relatively close to opposition (their closest approach), and as such the distance to travel is only 75,000,000 km.

Given this, your goal is to reach  Mars in time to minimize the losses from this attack. Your supervisor approves fuel expenditure up to 100,000 kg (the most that the Knight can hold) and asks that you keep total losses (from fuel and damages) to under $70,000,000 if possible. Can you do so?

In addition to the above, you may assume the following:

•  the Knight has a dry weight (mass without fuel) of 100,000 kg

•  Acceleration is close to instantaneous and follows the Tsiolkovsky rocket equation

 ,                                                                         (1)

where v is the velocity of the Knightve is the effective exhaust velocity, m0 is the initial total

weight of the Knight (dry weight plus mass of fuel), and mf is the dry weight of the Knight. • the Knight is powered by a specialized fuel that costs $1,000 per kg

•  The engines of the Knight can expel its specialized fuel with an effective exhaust velocity of 10,000 m/s

•  the Knight will travel uninhibited at its intended velocity until it arrives at Mars • You do not

need to consider deceleration upon arrival, nor the cost of fuel to return from Mars (though note that both could be modeled using Tsiolkovsky’s equation)You do not need to consider any other costs beside damages from the attack and fuel to make it to Mars.

You will develop a program to determine an effective amount of fuel to bring on the trip. If you bring too much, you may spend too much money on fuel to keep losses below $70 million. Ifyou bring too little, you may not accelerate to a high enough velocity to stop the damages in time.

If it is possible to keep total losses below $70 million, give an amount of fuel that allows you to do so. If not, give an amount of fuel that comes as close as you can, and state the total losses.

 

Lab 1

Part 1: Calculate the velocity

First, we will use Equation 1 to calculate the velocity of the Knight given an amount of fuel.

1.  If the Knight is carrying x kgs of fuel, what is its total weight?

2.  Create a variable fuel to represent the fuel mass and assign it some value in the range 0 to 100,000.

3.  Using Equation 1, the variable fuel, and the above information, calculate the final velocity of the Knight. You will need to import the math package. The function math.log(x) calculates lnx (the natural logarithm of x). Assign the velocity to a variable v.

a   to import the math package, add the statement bellow to the first line of your code:

import math

b   to call the log function:

math.log(equation__here)

4.  Print v using the print function.

Run your program. It should print the velocity resulting from the amount of fuel you chose.

 

Part 2: Compute other values

Using the velocity v that we have just calculated, we can now calculate the other values we will need for this project.

Duration

1.  Let’s call the distance between the Earth and Mars d. Given that it has velocity v, how long will it take the Knight to get to Mars? Consider acceleration to be instantaneous.

2.  In your program, use the variable v to calculate how long it will take the Knight to get to Mars, in seconds. Note that the distance between the Earth and Mars is given in kilometers. The velocity we’ve calculated above has units meters per second.

3.  Convert this time to days and assign it to a variable “days” .

4.  Print days.

Fuel cost           Next, use variable fuel to compute the total cost of fuel used. Assign this value to a

variable cost and then print it.

Losses from damage Calculate the losses due to the space pirates’ attack before the Knight arrives; use the estimated loss per day given by the intelligence crew in the Overview. Assign this value to a variable loss and then print it.

Total value lost Calculate the total value lost due to the space pirates’ attack. This includes both the cost of the fuel and the losses from damage. Assign this value to a variable net and then print it.

Run your program to see the velocity, duration, fuel cost, losses from damage, and total value lost for the amount of fuel you chose.

Part 3: Ask user for input

Now, rather than setting the value of fuel in the program, ask the user to enter an amount of fuel in kilograms. Then calculate and print the velocity, duration, fuel cost, losses from damage, and total value lost for this amount of fuel.

Hint: What function should you use to ask the user to enter a value? What type is returned by this function? What type does fuel need to be to do the computations you have already implemented?

Part 4: Run some experiments

Finally, use your program from the last part to experiment with different amounts of fuel to get an idea ofthe range of losses we will have to sustain due to the space pirate attack. Once you have       completed all parts of the lab, show your work to the lab instructor.