Friday, December 11, 2009

Final exams and final grades

Dear ChE170,

Your final exams have been graded and course grades have been assigned. You can find information on grade distributions at the course website. You can also find solutions to the final exam problems there as well. If you would like to pick up your exam, please stop by my office sometime.

I enjoyed the class this quarter, and we'll leave up the gallery for a while for all to admire your work. Good luck in your future courses and endeavors!

Cheers,
MSS

Monday, December 7, 2009

HW5

Dear class,
If you haven't picked up HW5 (or any other HWs), I will be bringing them to the art gallery at 5pm on Tues or you can pick them up at my office in ESB 3413.
Good luck on your finals,
Brad

Friday, December 4, 2009

Old HWs or Quizzes

Hi class,
If you have not gotten back any HWs or quizzes you can stop by my office in ESB 3413 anytime to pick them up. I will also be bringing them to the review session on Monday.
Thanks,
Brad

Some notes before finals

Dear class,

Just a few new announcements before the final on Thursday:
  • The final is closed notes and closed book, but you will be provided with the equation sheet given out in class today (handout 7, also on the web). Please bring pencils and a calculator. The final will cover all the material on the quizzes and problem sets.
  • A question-and-answer session will be held on Monday, 4-5pm in the chemical engineering conference room, EII 3319. We were unable to book the small classroom at this time, but with the small number of students that indicated interest in class, this room should be adequate.
  • A "gallery opening" will be held on Tuesday, 5-6pm, for your bonus projects. I will also invite the graduate students that were judges, and bring snacks. Feel free to stop by and take a study break.
  • The quizzes and their answer keys have been posted online.
Cheers and happy studying,
MSS

Tuesday, November 24, 2009

HW5

Dear class,

Please excuse the typo on HW5 - it is due Friday, 12/4, not Monday.

Cheers,
MSS

Friday, November 20, 2009

Problem 6c

Dear class,

In problem 6c on HW4, you may compute a faster rate of diffusion of the protein than for active transport. This is not an error -- I should have chosen a larger protein here.

Cheers,
MSS

Wednesday, November 18, 2009

Quiz and HW statistics

Dear class,

Here are the course averages thus far:

quiz 1: 81.1 +- 10.9%
quiz 2: 72.5 +- 16.5%
quiz 3: 78.6 +- 16.3%
quiz 4: 89.5 +- 8.9%

HW1: 81.6 +- 14.1%
HW2: 78.3 +- 12.8%
HW3: 87.0 +- 11.4%

Cheers,
MSS

Monday, November 16, 2009

Notational clarifications in HW4

Dear class-

I realized that there might be some notational confusion throughout HW4 regarding different R's - some of which specify the gas constant, some the cell radius, and some a protein radius. I have re-tooled the notation to be clearer so as to delineate these different quantities. I also made some clarifications on a number of problems: please check in particular the new problems 3 and 6c.

Cheers,
MSS

No office hours today or tomorrow

Dear class-

I will not be having office hours today due to travel to an NSF panel in DC. However, should you have questions about HW4, feel free to email me, stop by Wed or later in the week, or see Brad in his office hours.

Cheers,
MSS

Friday, November 13, 2009

Quiz 3 & HW2 avg scores

Class,
The average on Quiz 3 was a 78.6% and the average on HW2 was a 79.6%. I hope to be able to hand back HW3 by Wednesday's class. I have office hours today (Friday 11/13) at 3pm if you have any questions on the recently handed back HW or quizzes.
-Brad

Sunday, November 8, 2009

Grading with bonus project

Class-

There may be some confusion about the bonus project and how it will figure into your grade. Here's how we will compute your final grade.

At the end of the quarter after the final, we will first compute your grade as if there were no bonus project, but still dropping your lowest quiz score. From these grades we will compute the final grading scale (typically looking for natural breaks in the distribution) and assign you a letter grade.

Then, if you completed the bonus project satisfactorily, we will then recompute your grade two ways: one in which your second lowest quiz score is replaced with a 100% and one in which your final letter grade is bumped up by one +/- increment. Whichever of the two results in a higher final grade will be what we assign you.

In this scheme, missed quizzes will count as zero, but since we are dropping your lowest quiz score and since the bonus project gives you a second way to make up a quiz, this should permit you sufficient flexibility if you are unable to make a quiz for some reason. The purpose of the bonus project is to accomodate students who could not make a quiz due to conflicts and the rescheduling of the dates. As a result, we won't hold any make-up quizzes.

Hope that clarifies things,

Cheers,
MSS

HW4

Class-

HW4 is now posted online at the course website.

Cheers,
MSS

Thursday, November 5, 2009

Bonus project question

I was asked the following:
Does the project need to pertain only to one protein or can we use multiple proteins (i.e. DNA and a DNA polymerase)? Also, say we choose a small protein, can the artwork be a collage of multiple repeated units of that particular protein even if it isn't found like that in nature?
You can certainly include more than one molecule, especially if the function of them is best illustrated by a complex. As far as the layout, you can choose any way of displaying the protein that you like (collage, etc) so long as you are able to illustrate some kind of function within your project.

MSS

Updated course schedule

Dear class-

As discussed yesterday, there are some updates to the course schedule:
  • today, 11/5 -- Brad's office hours extended 3-5pm
  • tomorrow, 11/6 -- quiz 3 (Chapters 5-7, 10), also office hours canceled
  • Monday, 11/9 -- class canceled due to AIChE meeting, HW4 posted online
  • Tuesday, 11/10 -- Brad will be available for HW3 questions 11am-12pm
  • Thursday, 11/12 -- HW3 is due on Thursday, Nov 12 by 12pm in Brad's box
  • Friday, 11/13 -- HW4 will be handed out on paper
  • Monday, 11/23 -- HW4 due (normal due date)
  • Monday, 11/30 -- Quiz 5 will likely be moved to this date due to a guest lecture by Frank Doyle on Wednesday, 12/2
Also, the solutions to HW2 have been posted.

Cheers,
MSS

Wednesday, November 4, 2009

Office Hours Change and HW Mistake

Hello everyone,

As discussed in lecture this morning, I will not hold my normal Friday afternoon office hours this week and they've been rescheduled for Thursday at 4pm. That means I'll have office hours from 3pm-5pm on Thursday this week only. Also, feel free to email me any questions you have and we could arrange a time to meet sometime before the homework is due next Thursday, Nov 12 at noon (in my mailbox).

On number two of HW2 I misread the question as T>Tfold so if I took off points for your graph being wrong, please either show me your HW on Friday or place it in my mailbox and I'll give you the two points back. Sorry for the error.

Thanks,
Brad

Friday, October 30, 2009

Quiz moved again -> Friday

Class-

I received note from several students that will be taking the GRE next Wednesday morning. Therefore, as voted on in class this morning, we will have the quiz on the Friday of next week.

Cheers,
MSS

Wednesday, October 28, 2009

Quiz next week moved to Wed

Per the near-unanimous vote of the class, I will move the quiz from next Monday to next Wednesday. If this will cause a problem for you, please let me know immediately.

Cheers,
MSS

Thursday, October 22, 2009

HW2 notes

Hi class-

A couple of notes on HW2:

On problem 3, when you look at the description of the structure on the PDB website, there will be three different chains - two for thrombin and one for hirugen (a hiruden mimic). Hirugen will be about 12 residues long.

On problem 4, keep in mind that what is given is the fraction of the total that is folded ([F]/[F]+[U]), not the ratio of folded to unfolded ([F]/[U]).

On problem 6b, assume T = 300 K.

Cheers,
MSS

Talk on how to job interview

Hi class-

I received a note from Prof. Seborg that two ChE almuni will present a talk on "How to Succeed When Interviewing for an Industrial Job" today at 5pm in the Multicultural Center Theater:
The two speakers, Marc Privatera and Christina Borgese, were both AIChE Student Chapter presidents at UCSB. Marc was the UCSB recruiter for Clorox for several years and has had considerable experience interviewing ChE students. Recently, he moved to a biodiesel startup company, Biofuelbox, where he is the chief Technology Officer. Christina is a 2006 graduate who has worked at both Clorox and Biofuelbox.
Cheers,
MSS

Wednesday, October 21, 2009

Grade distributions thus far

Hi class-

Here are some statistics on grades for the first two quizzes and first homework:

Quiz 1
average +- std dev: 81% +- 11%
max: 96%
min: 52%

Quiz 2
average +- std dev: 73 +- 17%
max: 100%
min: 33%

Homework 1
average +- std dev: 82% +- 14%
max: 100%
min: 18%

Keep in mind that homework assignments count for 35% of your grade and quizzes 25%. In addition, remember that the lowest quiz grade will be dropped.

Cheers,
MSS

Friday, October 16, 2009

Interesting video

Dear class-

I highly suggest you take a look at this wonderful animation, entitled "The Inner Life of the Cell":

http://multimedia.mcb.harvard.edu/anim_innerlife_hi.html

It gives a molecular picture of most of the processes and compartments inside of a cell that we have been discussing. Although some of these are highly dramatized (for example, actin and tubulin assembly), the video does do an excellent job of integrating most of the major cellular processes and might make it easier for you to visualize the topics discussed in class.

Cheers,
MSS

Wednesday, October 7, 2009

Hints on HW1

Dear class-

Here are some hints on HW1 for the problems.

Problem 1:
In this problem, you are tackling a problem of combinatorics. The problem essentially asks you how many spots there must be in a DNA sequence that are variable (i.e., one of the four possible bases) in order to have 10^10 unique sequences.

Problem 2:
To compute how far proteins are from each other, you want to assume each protein sits in a little cube of volume. The distance between proteins is then V^(1/3). Therefore, to solve this problem, you have to first compute the volume per protein.

Problem 3:
For part b, first sketch out what the Coulombic interaction looks like. Then, sketch what the total LJ + Coulombic interaction would look like for small q, medium q, and large q. At some point, as you increase q, the minimum in the net potential should vanish. What are the mathematical criteria for the vanishing of a minimum? In other words, what two conditions involving the derivatives of a function must apply when a minimum becomes and inflection point? This provides two equations... what are the two unknowns?

Problem 6:
(b) Imagine that the protein is fixed at the origin. What conformations must the ligand give up when it binds?

Problem 7:
(a) To get from heat capacities to entropies and enthalpies, you will have to integrate from a reference temperature. What are the definitions of CP?

(b) To eliminate DeltaS(Tf) from your final expressions, you will need to let T = Tf and DeltaG= the value at the folding temperature, then solve your expression for DeltaS.

(d) You will want to use either the slope or intercept of some line to estimate DeltaH(Tf)

Problem 8
You are going to first want to write all of your equations in terms of K1, K2, K3, K4 where K1=exp(-DeltaG1/RT) and so on and so forth. Next, express the concentrations of the various bound hemoglobin species in terms of equilibrium constants, [O2], and [H]. What constraint governs the total concentration of hemoglobin? Write down a mass balance on concentrations of hemoglobin. Let [H]0 be equal to the total amount. Then, f0 = [H]/[H]0, f1 = [HO2]/[H]0 and so on and so forth.

Problem 9
This problem amounts to finding the probability of one molecular state relative to another one, using Boltzmann populations, P ~ exp(-U/kB T). Be sure to normalize the probabilities such that they sum to one.

That's all the hints for now. Good luck,

MSS




Problem

Sunday, October 4, 2009

Hints on problem set 1

Hi class-

If you're having a little bit of trouble getting started with PS1, here are a few hints for some of the more challenging problems.

On problems 6,7, and 9, you are using the Boltzmann population rules that we discussed in class. These may be new concepts for you, but these problems will help you grow comfortable in applying them. When you are working on these problems, you need to start by thinking about states: what are the possible states the system can have (e.g., folded or unfolded, bound or unbound, correct or incorrect nucleotide)?
  • Write down a list of all states.
  • Next, you need to assign a probability to each of the states, and that probability is given by the Boltzmann rule. You need to know the list of all of the states in order to normalize the probabilities, i.e., to ensure that they sum to one over all states.
  • Keep the following in mind for the Boltzmann rule. If your state consists of multiple possible molecular configurations, you want to use a free energy in the Boltzmann exponential. If it consists of only one, you can use the internal energy.
On problem 8, you will be using concepts from your earlier chemistry courses that should be more than familiar to you. Keep in mind that the equilibrium constant for a reaction relates to the reaction free energy by:

K = exp( - DeltaG0/ R T )

We'll eventually derive this rule in class this week. You will need to know this relationship in order to solve problem 8. Also keep in mind for problem 8 that the total concentration of hemoglobin molecules is constant, [H] + [H(O2)] + [H(O2)2] + [H(O2)3] + [H(O2)4] = const = [H]0. What you are trying to find is f0 = [H]/[H]0, f1 = [H]/[H]1, and so on and so forth.

Cheers,
MSS

Friday, October 2, 2009

Updated course website

Dear class-

I have posted the slides for the first three lectures and my notes for the lecture on thermodynamics on the course website. The thermo notes in particular may be helpful to you in thinking about and digesting today's lecture, and as you are working on the homework.

Cheers,
MSS

Wednesday, September 30, 2009

Updated office hours

Dear class-

The updated office hours for the course are as follows:

me (3321 Engr II)
Monday 3-4pm
Tuesday 11am-12pm

Brad (3201 Engr II)
Thursday 3-4pm
Friday 3-4pm

Cheers,
MSS

Sunday, September 27, 2009

HW1

Dear class,

If you have taken a look at the first problem set, be aware that some of the problems will relate to material that we will be getting to this week. Problems 1-5 relate to material that we will discuss on Monday and Wednesday, and Problems 6-9 to material discussed Friday and perhaps also next Monday. However, if you are eager to start these problems, the book reading assignment (Ch. 103) also provides background material that will be pertinent to them.

Cheers,
MSS

Friday, September 25, 2009

TA Office Hours

Dear ChE170 students,

As discussed in today's lecture, my office hours are Tuesdays & Fridays at 3PM in room 3201 ENGRII. Also, there was a typo in the syllabus: my email is spatola@umail.ucsb.edu, with an o, NOT spatula like the kitchen utensil.

Thanks,
Brad Spatola

ChE170

Dear class-

Welcome to the course announcements blog for ChE170: Molecular and Cell Biology for Engineers. To receive announcements automatically by email, I encourage you to add your email to the subscription box to the right. Your email will be removed at the end of the course.

Cheers,
MSS

Friday, June 19, 2009

Final project gallery

Dear ChE210D class members,

I have completed turning your final projects and movies into an online gallery at the course website. You can find it at this link:

http://www.engr.ucsb.edu/~shell/che210d/gallery/index.html

Enjoy!

MSS

Friday, June 12, 2009

Final projects

Dear ChE210D-

Great job on the final projects! I was thoroughly impressed with what you all were able to do in such a short period of time. I will be away next week at a workshop, but the following week I will compile the projects into a web page for you all to view and vote on your favorites.

Also, I placed your graded final project back in your mailbox if you are a ChE graduate student. Otherwise, you can stop by my office the week after next to pick them up if you want them.

I hope you all enjoyed the class. From the look of the projects, it seems that you learned a great deal. Down the road, I'd be greatly appreciative if you would let me know how your projects develop (if you continue them) and, in particular, what parts of the course turn out to be the most useful for you.

Have a happy and productive summer,

MSS

Tuesday, June 9, 2009

Final project CDs

Dear class-

I have a group meeting from 4-5pm tomorrow, but you can submit your final project either by: putting it in my mailbox or by sliding it under my office door. The former is preferred so that I don't inadvertently step on any CDs.

Cheers,
MSS

Friday, June 5, 2009

Screened Coulomb potential (correction)

Class,

I found a typo in the lecture notes on the screened Coulomb potential in the definition of epsilon_Coul. This has now been corrected.

MSS

Tuesday, June 2, 2009

Screened Coulomb potential

Class,

If you are using the screened Coulomb potential in your final project (to avoid Ewald summations), there may be some details to picking appropriate length and energy scales for non-dimensionalizing you simulation units. I have added to the lecture notes some comments on how you might go about doing this. You can find a short derivation in the very last section of the lecture notes on classical force fields.

Cheers,
MSS

Wednesday, May 27, 2009

Final project template

Dear class,

I have posted on the course website the template for your final project report. Please use this template as it will ensure consistency when I compile the virtual simulation gallery.

Also, please do keep in mind that the report is intended to be very brief. I have listed some target numbers of sentences for each section. You do not need to prepare an extensive report for the final project. Essentially the report will serve to introduce the reader to your simulation approach and provide some background for the work and movie.

As you are working on or thinking about your final project, keep in mind that you want to keep it simple. I am not looking for extensive simulations here; rather, I simply want you to have some experience putting together your own model and simulation code. This should not be a terribly time-consuming project. If you are having trouble formulating a simple project, please see me or take a look at the suggestions in the final project handout.

Also, I have posted all but one of the remaining lecture notes, in case you are interested in reading ahead as you work on your project.

Cheers,
MSS

Wednesday, May 20, 2009

Visualization

Dear class,

Next Tuesday's lecture will cover visualization methods, but if you are starting to work on your final project and are interested in how to make a movie, I have posted a tutorial handout on visualization on the course website that I will distribute on Tuesday. The procedure is actually quite straightforward using the program UCSF Chimera, but you may want to run a quick test.

Cheers,
MSS

Tuesday, May 19, 2009

Advanced methods in final project

Here are some other ideas (perhaps more straightforward to implement) that would be acceptable as advanced methods in your final project. Keep in mind you only need to implement one if you do not do Ex 5:
  • Andersen thermostat in MD (note that this is not what we have used before--you will need to resample velocities from the Gaussian Maxwell-Boltzmann distribution using np.random.normal)
  • Berendsen thermostat in MD (you will need to rationalize a good value for the coupling constant tau)
  • any MC move that is not a usual (unbiased) single-particle displacement
  • block averaging analysis (to compute estimated errors in an observable)
  • computation of any histogram (e.g., computing any distribution -- you might examine how this changes with some parameter)
MSS

Monday, May 18, 2009

Correction for reference in Ex 5

In exercise 5, there is a reference that is incorrect. The graph included corresponds to the following paper:

Phys. Rev. E 72, 021501 (2005)

This may be helpful in comparing your computed densities and pressures.

Cheers,
Scott

Some helpful models for the final project

There are two models that may be useful for developing simple models in your final project.

One is the screened Coulomb potential, which is a very simple, approximate pairwise potential for reproducing electrostatic interactions that does not require a special treatment of the long-range interactions (e.g., the Ewald summation).

The other is the Lennard-Jones wall or surface potential, which is used to approximate the net interaction of an atom with an infinitely wide and deep surface of uniform density.

Both of these have now been added to the lecture notes on classical force fields. You can find the equations for the energy functions there.

MSS

Friday, May 8, 2009

Please bring Ex2, 3 to class Tuesday

Dear class,

My excel file for the course grades has become corrupted and I cannot recover your grades for exercises 2 and 3. Please bring these graded assignments to class on Tuesday so that I can mark these down. Apologies for any inconvenience.

Cheers,
MSS

Thursday, May 7, 2009

Final project

Dear class-

I have placed the final project assignment on the course website. This handout will be discussed further in class on Tuesday.

Keep in mind that you have the choice of completing Exercise 5 or you can implement an advanced technique in your final project (as described in the handout).

Cheers,
MSS

Wednesday, May 6, 2009

Extension on ex 4

Hi class-

If you prefer to turn in your assignment by Friday at 4pm (either to me, under my door, or in my mailbox), that is fine.

Cheers,
MSS

Typo in Ex4, part e

The expression for the virial pressure should be as follows:

= < (N kB T)/V - W/3V >

The original expression was missing the 3 and the averages should be performed over the entire expression (both V and W fluctuate).

MSS

Tuesday, May 5, 2009

Even more on Ex4

There is a slight typo in the lecture notes that I believe may cause confusion regarding your homework. When we perform a simulation in reduced units, such as the monatomic Lennard-Jones system, Boltzmann's constant kB is absorbed into the dimensionless temperature:

T* = kB T / epsilon

Thus, the acceptance criterion does not explicitly contain the quantity kB. Another way of thinking about this is that kB = 1 for reduced units:

Pacc = min{ 1, exp[ -(U2* - U1*) / T*] }

The point is, you should not need to specify kB in your simulation runs.

MSS

More on Ex4

Hi all-

In your Fortran loop to compute the interaction energies between a selected atom and all other atoms, you will have to modify the test between atoms i and j to see if they are bonded or not. The reason behind this is that your loop will no longer run over pairs (i,j) such that j > i always. The following Fortran code will test if any two i or j are bonded:

abs(i-j) == 1 .and. mod(max(i, j), M) > 0

Also, if you are using f2py, be sure to keep in mind that you should always place dimension variables (e.g., NAtom, Dim) at the end of your subroutine declaration statement. The reason for this is that f2py will automatically re-order subroutine arguments this way, and it might come as unexpected when you are calling these compiled routines from Python. In any case, you do not need to send these variables to the Fortran routine when you call them from Python as f2py will automatically take them from the dimensions of the other variables you send (e.g., Pos).

Cheers,
MSS

Monday, May 4, 2009

Exercise 4

For this assignment, let's only consider the cases M=1,2,4. The original problem statement included longer-length polymers, but I think we might run into problems with sampling at these lengths.

MSS

Tuesday, April 14, 2009

Sums in NumPy

Class,

It was just pointed out to me that there is a difference between sum and np.sum. Consider the following,
>>> a = np.array([[0,2,3], [5,2,3]], float)
>>> sum(a)
array([ 5., 4., 6.])
>>> np.sum(a)
15.0
The sum function will only sum an array along the smallest axis, while the np.sum function sums the entire array. For your dot products, you want to use the np.sum function instead of just sum.

MSS

Typo and hints on f2py in Ex2

Dear class-

There is a typo in the global minimum energy for N=9. It should read 24.1134, not 21.1134.

Also, if you are having trouble getting f2py working on Windows, here are some potential troubleshooting steps:

(1) Close out and re-open your command prompt after any change to the system (e.g., environment variables).

(2) Re-download libpython25.a from the course website and install it in c:\python25\libs (plural).

(3) When running f2py at the command line, try "python c:\python25\scripts\f2py.py" instead of just "f2py".

(4) If all else fails, reinstall Python. First, uninstall VPython, SciPy, NumPy, and Python from Add/Remove Programs. Then, delete the folder c:\python25 entirely. Next reinstall these utilities in this order: Python, NumPy, SciPy, and VPython. You may want to hold off installing VPython until you've tried to get f2py to work.

I apologize for any headaches here, but once you have everything installed, it will be smooth-sailing from now on. Moreover, rest assured the Python/SciPy/NumPy development communities are working to automate /streamline installs so that you shouldn't have to worry about these issues down the road.

-MSS

Monday, April 13, 2009

Dot products in exercise 2

The vectors described in the notes on minimization correspond to vectors in 3N-dimensional space. Therefore, the dot products for the conjugate gradient formulas indicate the multidimensional dot product in 3N-dimensional space. In other words

f^N . f^N = fx,1^2 + fy,1^2 + fz,1^2 + fx,2^2 + ... + fz,N^2

The result should be a scalar.

You will be working with (N,3) arrays in NumPy. For these kinds of arrays, NumPy's dot product will not give you the behavior above, since this function is a generalized matrix multiplication and NumPy will think your two-dimensional array is intended as a matrix, not a 3N-dimensional vector.

Instead you want to use something like:

np.sum(Forces**2)

Or,

np.sum((Forces - OldForces) * Forces)

Here, this code indicates that the Forces array will be squared on an element-by-element basis, and then these 3N elements will be summed.

Cheers,
MSS

Correction on installing f2py in Windows

Dear class-

I realized there is a mistake on the web page and in the tutorial on f2py. It says to download and place the file libpython25.a in the following location:

c:\Python25\lib\libpython25.a

This is an error. There is both a lib folder and a libs folder, and the file should be placed in:

c:\Python25\libs\libpython25.a

If there is already a file there with that name, you can overwrite it. The true libpython25.a should be about 700 kB in size.

MSS

Thursday, April 9, 2009

Ex1

Dear class,

If you are a chemical engineering grad student, I am going to put your Exercise 1 results in your boxes so that you have the comments as you begin to work on Exercise 2. If you are in a different department or are an undergrad, you can see me in my office to get yours back, or you can just wait until Tuesday.

There were only two main coding points that I want to emphasize.

The first is to keep in mind that Python indexing starts at 0, not 1. Moreover, slice notation is exclusive of the upper bound. So to take text from the third to and including the 10th columns in a pdb file, use line[2:10]. The 2 and 10 designate the third and 11th characters in line, but the upper bound is not included in the slice.

The second is to keep in mind that Python enables you to iterate over lists directly. Instead of:
for i in range(len(PdbFiles)):
PdbFile = PdbFiles[i]
...
use the following:
for PdbFile in PdbFiles:
...
In addition, we can use list constructors to make our code much clearer. Consider the following code:
Phobics = ["ALA", "CYS", ...]
IsPhobic = []
for Res in ResNames:
if Res in Phobics:
IsPhobic.append(True)
else:
IsPhobic.append(False)
This can be made much shorter and clearer using:
Phobics = ["ALA", "CYS", ...]
IsPhobic = [Res in Phobics for Res in ResNames]
These hints aren't to curb your programming style, but rather help you take advantage of Python's programming features so that ultimately you will be able to write code very efficiently. Moreover, when you take advantage of Python's and NumPy's built-in routines and syntax, your code actually executes much faster.

Hope that helps as you are beginning Exercise 2.

Cheers,
MSS

Wednesday, April 8, 2009

Some benchmarks and coding hints

Dear class,

If you are having trouble with your code, let me provide some help here.

First, if you are wondering what some typical results are, I am getting Rg values to be in the range of about 14-24 (in Angstroms) and the ratio to vary between roughly 0.90 and 0.98.

Second, it is important that you consider the notation |r| to denote a vector norm. That is, it gives the length of the vector r. Thus,

|a-b|^2

gives the squared length of the vector pointing from b to a. This could be expanded as:

(xa - xb)^2 + (ya - yb)^2 + (za - zb)^2

where a = (xa, ya, za) and b = (zb, yb, zb).

Now, consider the radius of gyration. For a set of points, this is simply the root-mean-square-distance of the points from their centroid, where the centroid is defined as the average position of the points.

For the function you are to write called RadiusOfGyration, you need to compute the centroid and, subsequently, the squared distances of each position from it. To compute the centroid, you might write this code:
rm = np.zeros(3, float)
for (x, y, z) in Pos:
rm[0] = rm[0] + x
rm[1] = rm[1] + y
rm[2] = rm[2] + z
rm = rm / len(Pos)
Better yet, we could use the fact that NumPy allows element-by-element operations on arrays:
rm = np.zeros(3, float)
for Point in Pos:
rm = rm + Point
rm = rm / len(Pos)
Even better yet, we could use the sum function and specify that we want to sum over the first axis, the one corresponding to the particle index:
rm = Pos.sum(axis=0) / len(Pos)
Best yet, we can use the mean function:
rm = Pos.mean(axis=0)
Once we have computed the centroid, we might compute the Rg as follows:
RgSq = 0.
for (x, y, z) in Pos:
RgSq = RgSq + (x-rm[0])**2 + (y-rm[1])**2 + (z-rm[2])**2
Rg = np.sqrt(RgSq / len(Pos))
Again, we can use element-by-element operations:
RgSq = 0.
for Point in Pos:
RgSq = RgSq + sum((Point - rm)**2)
Rg = np.sqrt(RgSq / len(Pos))
Even better, we can use NumPy's broadcasting feature:
RgSq = sum((Pos - rm)**2)
Rg = np.sqrt(RgSq / len(Pos))
Here, Pos is an (N,3) array and rm is a (3) array. In taking the difference between the two, NumPy automatically broadcasts rm to be the same shape as Pos by duplicating it over N times.

Putting everything together, the RadiusOfGyration function can be completely written in a single line:
return np.sqrt(sum( (Pos - Pos.mean(axis=0))**2 ) / len(Pos))
Hope that helps,

MSS

Tuesday, April 7, 2009

Correction to ex1

Hi class-

In the exercise 1 assignment, it states to use:

Pos[IsPhobic]

to grab just the positions of the hydrophobic residues. This does work, but only if IsPhobic is a NumPy array of Boolean values. If you have made IsPhobic as a list (which is most likely the case), you'll have to convert it to an array:

IsPhobic = np.array(IsPhobic, bool)

Apologies for the confusion,
MSS

Monday, April 6, 2009

EX1

Hi class-

It was just pointed out to me that some of the protein structure files I posted have some complicating factors in them that can result in multiple alpha carbon coordinates for the same amino acid. I have now preprocessed and cleaned up these files. You should download the new proteins.zip or proteins.tar.gz files from the website.

Also, here are some more programming hints:

When you are parsing a pdb file, be sure to take the exact columns that the pdb format specifies. The different fields are not necessarily separated by spaces and so splitting a string apart can fail. You can access specific subsections of a string using slice notation. For example, if line is the variable containing the contents of a line read in from a file, you can get columns 18-20 (inclusive) using the notation line[17:20].

Also, you can use Python's list constructors to your advantage. For your function that returns the IsPhobic array, you can easily iterate over the residues in a form like:

[Res in Phobics for Res in ResNames]

where Phobics is a list containing hydrophobic amino acid names. The "in" statement here will result in either a True or False value so that the constructed array will contain only Booleans.

Cheers,
MSS

More hints for exercise 1

When reading a pdb file, you might want to first create two empty lists and add to them as you are parsing the lines. At the end, you can turn the position list into an array. For example,
Pos = []
ResNames = []
for line in file(PdbFile, 'r').readlines():
if line.startswith("TER"):
#break out of the loop over lines
break
elif line.startswith("ATOM"):
#check to see if it's an alpha carbon
if line[12:16].strip() == "CA":
#.... your code here to get x, y, z
#and ResName from the string line...
Pos.append([x, y, z])
ResNames.append(ResName)
Pos = np.array(Pos, float)
MSS

Thursday, April 2, 2009

Python and support packages on Macs

Nathan D. has graciously shared some instructions for getting Python, NumPy, SciPy, and gfortran installed on Macs. Let me know if this doesn't work out for you:

1) Install the python package from here:
http://wiki.python.org/moin/MacPython/Leopard

2) Run this script to install SciPy, NumPy, and gfortran which you can download here:
http://macinscience.org/?page_id=6

MSS

Hint on EX1

Dear CHE210D class:

In working on exercise 1, there are many ways to make your code very short using Python's string functions and list expressions & objects. Your final code should actually be quite short. For example, to test whether or not a given amino acid name is hydrophobic, you could use something like the following
>>> Phobics = ["ALA", ... , "TRP"]
>>> s = "ALA"
>>> s in Phobics
True
>>> s = "ARG"
>>> s in Phobics
False
-MSS

Tuesday, March 24, 2009

Top exam scores

Class,

Incidentally, I should have mentioned that the top score on the final was 174/200. In addition, there was at least one perfect answer submitted for every problem.

MSS

Final exam and course grades

Dear CHE110A,

We have finished grading your final. Your course grades have been determined and will be posted to the egrades system shortly.

Here are some statistics for you:

Final:
60% average
14% standard deviation

Course grade counts:
3 A+
3 A
3 A-
3 B+
9 B
5 B-
2 C+
5 C
3 C-
3 D+
1 D
3 F

I have posted plots of the grade distributions at:
www.engr.ucsb.edu/~shell/che110a/finalgrades.pdf

If you would like your graded exam back or want to discuss your grade, please stop by my office. I will be here most of the week, including all of this afternoon 2-5pm. We won't post solutions, but in correcting your finals, we have made an effort to indicate the correct strategy.

Lastly, as for the elective I did not take as an undergrad -- that was art history.

Good luck in your future studies!

Cheers,
MSS

Thursday, March 19, 2009

Pre-Final

Hi Class,
If you're looking for me today, I'll be between my office and the office-hour room (3301).
-Avi

Wednesday, March 18, 2009

Odds and ends

Dear class,

Solutions to HW8 and 9 are posted on the course website. In addition, solutions to the problems worked in the review session last night are posted there. If you have not received your graded HW8, please see Avi (Engineering II 3218). Due to HW9's due date of last Friday, we probably won't be able to get these graded before the final exam, but you should be able to review these problems using the posted solutions.

In preparing for the final, keep in mind this general problem solving strategy:

  1. Make diagrams and/or tables to organize problem information.
  2. If a problem involves many steps, break it into individual processes.
  3. To each step, apply the first and second laws, choosing the version (closed or open) as appropriate.
  4. Identify any quantities that are constant or zero and use these to simplify the first and second laws.
  5. Determine any quantities that you can solve immediately: Q, W, DH, DS, DU, etc.
  6. Use substance-specific data to solve for the remaining quantities: charts, steam tables, PVT EOS, Cp models, generalized correlations, etc.
This strategy should carry you through almost any thermodynamics problem and will, at the least, earn you partial credit.

Good luck on the final! I've enjoyed teaching you all this quarter and hope you continue to stay in touch as you progress through the curriculum,

Cheers,
MSS

Monday, March 16, 2009

Review Session

Hi Class,
The problems for the review session have been posted.
-Avi

Wednesday, March 11, 2009

Review Session

Hi Class,
So as decided today in class, there will be a review session next Tuesday (March 17) between 7-9 pm in room 3301 (the usual classroom in which I hold office hours). In the first hour, I will solve a problem (which will be posted by next Monday). In the second hour, you can ask me anything you want - so come prepared :)
-Avi

Tuesday, March 10, 2009

HW9

Dear class-

Here are some clarifications / hints for HW9:

Problem 48: You will want to use the tabulated Pitzer correlations in the tables at the back of the book (which we reviewed in class), not the analytical virial coefficient equations (which we did not).

Problem 49: Think about which intensive property you can determine for the final state of the system, after one phase has disappeared. Recall that the book provides values for V, U, H, and S in the steam tables.

Problem 52: Notice that there are no tables for the properties of subcooled water. This is because liquid water at higher temperatures can be modeled to a reasonable degree with analytic equations. Therefore, for the pump part of this problem, you will have to use the equations presented in class for computing enthalpy changes in liquids in the isentropic and general cases. You might beware that there are some typos in eqns 7.25 and 7.26 in the book.

MSS

Wednesday, February 25, 2009

HW8, problem 44

Normally I have a demonstration that I do in class where I freeze supercooled water; however, because the classroom is so far from my office fridge, the water won't make it without freezing or heating too much.

But if you want to see the demonstration, stop by my office at office hours or if the door is open and I'll show you it.

Youtube also has tons of videos of this, and you can easily do it at home. You just need to find really pure bottled water.

MSS

Friday, February 20, 2009

Ideal gas entropy

Hi class-

If you are interested in seeing the full treatment of the ideal gas entropy starting with Boltzmann's equation (S = k ln Omega) that includes kinetic energies, there is a short, two-page derivation in my graduate course that is at the level you should be able to understand. To read it, follow this link and go to page 14.

Have a good weekend,
MSS

Monday, February 16, 2009

Typo on Problem Set #6

Hi Class,
There's a typo on Problem 32. The second reaction is:
CO + H2O --> CO2 + H2
(the coefficient in front of H2 should be 1 instead of 3).
-Avi

Sunday, February 15, 2009

Office Hours on President's Day

Hi Class,
While it's a holiday tomorrow, I'll be at school tomorrow, and hence, I intend to hold office hours. So, if you have questions about the problem set, stop by between 4-5 pm (if I'm not in 3301, I'm in my office). In any case, there will also be office hours on Tuesday as usual.
-Avi

Friday, February 13, 2009

Midterm exam notes

Hi class-

I realized that I swapped your midterm and the midterm without bonus numbers on your mid-quarter progress sheets. The higher of the two is the midterm with the bonus points included. In general, the bonus points didn't really shift the course distribution.

The letter grade ranges listed at the bottom of the sheet are highly approximate, and perhaps slightly more stringent than what will likely be the case. Here are some statistics from last year's course:

A > 79% (6 students)
B > 71% (21)
C > 57% (19)
D > 53% (4)
F < 53% (3)

Keep in mind that these grade ranges factor in the final, which is 45% of your grade. The average on the final last year was 63% with a standard deviation of 16%.

Ultimately, in assigning letter grades, we tend to look for natural breaks in the score distribution, but we also take into account the class performance as a whole relative to previous years.

Please do see me if you have questions about the midterm or the material this far. It is very important that you have a good understanding of all of the material up to this point, as we will only build on it in class.

MSS

Friday, February 6, 2009

Hi Class,
I realized I made a slight mistake on Wednesday in my solution for #1. That mistake gave me a total positive work (while it should be negative for such a cycle). The root of the mistake was that I took V1 to be the experimentally observed critical volume rather than the theoretical (van der Waals) critical volume. Thus, the equation of state was violated at the critical point, and an erroneous process was obtained. I made the corresponding corrections in the solution (it should be posted later today).
-Avi

Thursday, February 5, 2009

Midterm Exam

Hi class,

The midterm will be this coming Monday in class. It will be open book and you are allowed to bring one letter size page of handwritten notes, front and back. Please bring your calculators. The test will last 50 minutes.

Avi will hold a review session at 3pm on this Sunday in room 3301 in Engineering II. This will not be a planned lecture or problem session but a time that you can ask questions about the course material or study sheet.

Cheers,
MSS

Tuesday, January 27, 2009

Also, regarding problem 18, while you can present your answer in Btu/s, it is better to give it in hp (horsepower). Thanks.
-Avi
Hi Class,
I have a few notes for this assignment:
- For problem 16, since temperatures are given in English units, present your answers in Btu/lb-mol
- For problem 17, you can use 4.18 kJ/kg*K for the Cp of water
These two comments also apply for the rest of the course.
-Avi
Hi Class,
I'm not sure if you know this but just in case:
My office is #3218
-Avi

Monday, January 26, 2009

Monday Office Hours

Hi Class,
I'm sorry, but something has come up, so I need to cancel today's office hours. To make up for this, I'll extend my office hours tomorrow - it will be 5-7pm. Furthermore, I will be avaliable all day tomorrow in my office, in case you have some questions for me. Also, feel free to send me an email.
-Avi

Thursday, January 22, 2009

Problem 19

The formula for the cost stated on this problem is in dollars ($).
MSS

Wednesday, January 21, 2009

Solution to part d of problem session

Hi class-

The correct solution to part d of the problem session we worked in class today is:

eta = 1 - (1/r)^(gamma - 1)

In class, I initially wrote (1-gamma) incorrectly.

Please do spend 10 minutes working parts (c) and (d) if you haven't already gotten to the answer. This will help prepare you when you start your problem set.

Cheers,
MSS

Tuesday, January 20, 2009

Thought problem on HW3

Hi class,

For this problem, you will want to come up with an analytic expression for the work that involves only the temperature T, the initial and final volumes and pressures (V1, V2, P1, P2), and an integral int f(P) dP, since these are the things that you know or could do, according to the problem statement.

MSS

Friday, January 16, 2009

By the way, regarding the thought porblem on this problem set, you'll need to show some calculus (rather than just abstractly discuss it).
Hi Class,
Although Monday is a holiday, I'll be holding office hours that day if anyone is interested. If I'm not in the regular classroom, that means I'm in my office (feel free to pop in). In any case, there'll also be office hours on Tuesday.
-Avi

PS2 thought problem

A quick note: instead of "chain rule" it should say "product rule". Also, you may recall that the product rule in integral calculus takes the form of "integration by parts."

Monday, January 12, 2009

HW2, problem 6 hint

By definition, the constant-pressure heat capacity is given by

Cp = d(U + PV)/dT

However, for liquids the molar volume V changes very little upon heating. Therefore, at constant pressure, we can neglect the second term to good approximation in liquids:

Cp ~ dU/dT

Rearranging, we arrive at an equation we can integrate to get a relation between U and T:

Cp dT = dU

-MSS

Discussion section time

I was asked if it would be possible to move the discussion section time, if the entire class were able to agree upon some other choice. Unfortunately, this would be very difficult to do since, in addition to making sure that it worked with each students' schedule (a challenging task), we would need to go through an official request with the registrar to find another suitable room. Therefore, I believe we must leave the time as it is. Apologies, but sometimes this is just how things work out.

Cheers,
MSS

Thursday, January 8, 2009

Hi Thermo Students,
On problem set #2, realize that the "ton" and the "gal" are the US units (since we don't live in the UK). Here are the corresponding conversions you need to use:
1 ton = 907.18 kg
264.17 gal = 1 m^3
Just remember that the same goes for all subsequent problems you will have in the course...
-Avi

Office hours

Dear class,

Office hours for the course will be as follows:

Friday 1:00-2:50pm - my office
Monday 4-5pm - Engr II 3301
Tuesday 5-6pm - Engr II 3301

MSS

Tuesday, January 6, 2009

Also, I forgot to reiterate one more thing. Remember, this is not an actual project you will have to do, this is just a fictitious proposal.

Problem Set No. 1

Hi Class,
I just wanted to clarify for you the thermo you need to discuss in your email. For my example, I'll use the steam engine. So, just as Dr. Shell mentioned in class, do not pick this as your example.

Foremost, you want to discuss the thermo embodiment in your example. You can discuss: different transformations in energy, driving forces, phase changes, connection of entropy, etc.
My example - Heat flows from the hotter firebox to the colder boiler, making chemical energy in fuel transform into mechanical energy in machinery...

Also, you want to discuss a possible thermo analysis aspect of your example (something that would be interesting to calculate if implementing the example). You can discuss: optimum operating conditions, energy efficiency, amount of heat/work, solubility limits, etc.
My example - It would be interesting to calculate the required operating temperature of the firebox and boiler that yields the optimum energy conversion efficiency...

In any case, the entire goal of the assignment is to have you communicate in a scientifically proper way. So, you will be mostly graded for language/format. I don't have official office hours this week, but if you have any questions, feel free to contact me by email or to stop by my office.
Cheers,
Avi

Monday, January 5, 2009

ChE110A W09 Problem Set 1

Dear class-
For this assignment, just send a plain-text email memo. There is no need to compose the memo in a separate document and attach it.
MSS