Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Programming Assignment 4 average length of polymer Please complete all parts and share your all code in C++. Physical Chemistry Polymers such as proteins consist

Programming Assignment 4 average length of polymer

Please complete all parts and share your all code in C++.

Physical Chemistry

Polymers such as proteins consist of long chains of atoms or molecules. While there are some restrictions on how they can form and what shape they have, to a large extent they can be modeled by a random walk.

We'll consider a simplified example in which you can assume that

1) that each "step" has the same length of 1 unit,

2) while each link must be connected to the previous link, it may be connected at any angle, i.e., the probability of any angle is the same (there is a uniform distribution on the angles).

3) to simplify the problem, do this in 2 dimensions, not 3.

By running many simulations, estimate the average length from one end of the polymer to the other if the polymer consists of 4000 links.

4) the monomer can overlap and cross. (If we dont make this simplifying assumption, then the problem becomes significantly more difficult.)

Hint: as we discussed in class, you would find out the true nature of a coin by flipping it many times. You want to find true nature of these polymers, in specific, the average end-to-end length, by creating many of them.

How many is many. You need to create a lot of polymers. On the other hand, I dont want your code to take several weeks to run. The executable code created by your program should take about 5 seconds at most to run. C++ is a fast language, and this amount of time will be sufficient to get a good estimate of the average end-to-end length.

Please follow the naming conventions for the program and the subject line. These are very useful for me in locating your work and processing it in a timely manner. If these conventions arent followed, it becomes significantly more difficult for me to find your work. In this event, I cannot guarantee that your assignment will be graded in a timely manner.

Problem-solving phase

There are several things you will need to address in writing this program. Some of these include the following:

*How to select a direction for the monomer to point. Every direction must be equally likely

*How to attach the new monomer to the polymer

*How to calculate the distance from one end of the polymer to the other.

*How to represent the monomers and the entire polymer mathematically and in code.

Notes regarding applications

What chemists are most interested in is the maximum length of the polymer (this is the maximum length of the end of any link to any other end). This length is related to how the polymer diffuses in water. The end to end length is closely related to the maximum length, and its easier to calculate.

Some useful hints:

Look for the following commands in your textbook (or on the internet)

random(), which creates a pseudorandom number. Requires cmath library (like iostream). random(1000) will get a pseudorandom integer in interval [0,999]

In general, random(n) will get pseudorandom integer in interval [0,n-1]. n should be a positive integer.

A random number generator such as rand(). Look in the textbook for a discussion of the syntax related to this and also how to use it.

The operator, % , which gives you the remainder after dividing by some number

for loops (see textbook).

if-else statements (see textbook)

Variable type, int and double

trigonometric functions such as sin(x) and cos(x) are in the cmath library. You may wish to include this library in your program just as youve done for iostream.

Other resources

As the bulletin states, the formal prerequisite is high school algebra. In case, you need to review the basics of high school algebra, the following online resources could be useful for you.

The first site focuses on trigonometry, which could be helpful for this programming assignment.

Trigonometry: http://tutorial.math.lamar.edu/Extras/AlgebraTrigReview/TrigIntro.aspx

Algebra: http://www.wtamu.edu/academic/anns/mps/math/mathlab/

Online book (in pdf):

http://tutorial.math.lamar.edu/pdf/AlgebraTrig.pdf

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Data Access Patterns Database Interactions In Object Oriented Applications

Authors: Clifton Nock

1st Edition

0321555627, 978-0321555625

More Books

Students also viewed these Databases questions

Question

1.who the father of Ayurveda? 2. Who the father of taxonomy?

Answered: 1 week ago

Question

Commen Name with scientific name Tiger - Wolf- Lion- Cat- Dog-

Answered: 1 week ago