cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
Showing results for 
Search instead for 
Did you mean: 

Molecular Weight Function

ptc-3828039
Newbie

Molecular Weight Function

I am looking for a function in MathCAD Prime that will give me the atomic or molecular weights of elements or molecules. There is a function in Excel called mw() where you add the name of an atom or molecule in quotes and it gives you the weight per mole. For example =mw("Li2CO3") produces 73.89138.

 

As a chemical engineer this would be a very useful function in MathCAD and frankly I'm surprized it isn't in the base functionality.

 

Can anyone suggest how one might try to implement this functionality?

 

Thank you in advance!

 

Mike McNamara, P.E.

Simbol Materials

23 REPLIES 23

Re: Molecular Weight Function

In Mathcad 15:

pt.png

Re: Molecular Weight Function

Do you mean something like the attached? (Needs work to handle molecular formulae with parentheses).

Stuart

Re: Molecular Weight Function

Stuart,
If you modify this file, it will be fine chemical Mathcad-calculator!
Valery,
This is a very good idea for a Mathcad Calculation Server.

mw.GIF

Viktor

Re: Molecular Weight Function

Viktor Korobov wrote:


Valery,
This is a very good idea for a Mathcad Calculation Server.

Yes, I will add this site:

http://twt.mpei.ac.ru/MAS/Worksheets/Chem/solutions.html

Re: Molecular Weight Function

ummm - you're a cruel man, Viktor. It's late and I'm tired (notice that I'm getting my excuses in early ) so you are taxing my poor brain well beyond its meagre limits. I'll compromise and try to give the weight of the first of your two formulae ... the solution lacks elegance, though. On the plus side, it does involve Recursion.

However, I suspect that I'll actually have to Think About the second one ...

I haven't had time to check the worksheet over but it looks like it's giving roughly the right answers for the limited test cases that I've tried.

Stuart

Re: Molecular Weight Function

I've just had a quick glance at the worksheet again and it's actually blindingly obvious how to approach this ... provided I've interpreted the '*' correctly. I use the base str2mat function to split the expression at the asterisk, vectorize getList over the resulting expression array, carry out any pre/post multiplication of each expression and then merge the lists. I've shown the process below (minus the H20 multiplication by 18) because that would involve actual work ... and, to be honest, I'm not familiar enough with chemical notation to know what the scope of the '18' actually is (I'm guessing over all the H20 but I don't know how far it would extend over longer expressions. Is there a decent reference that explains the format?

Stuart

collab - 12 06 26 molecular weights 01.jpg

Re: Molecular Weight Function

StuartBruff wrote:

.... Is there a decent reference that explains the format?

Maybe there?

http://www.webqc.org/molecular-weight-of-Al2(SO4)3*18H2O.html

mwcalc.GIF

Cruel man Viktor

Viktor

Re: Molecular Weight Function

Viktor Korobov wrote:

StuartBruff wrote:

.... Is there a decent reference that explains the format?

Maybe there?

http://www.webqc.org/molecular-weight-of-Al2(SO4)3*18H2O.html

mwcalc.GIF

Cruel man Viktor

Unfortunately, Viktor, I couldn't see anything that was particularly explicit about the format ... it looks like Chemists are born with the knowledge .

Stuart

Re: Molecular Weight Function

I agree that Stuart has created a wonderful document. But it does not work for all cases. In particular, we have false results for the molar masses of double salts and crystalline hydrates.

Viktor

Re: Molecular Weight Function

Viktor Korobov wrote:

But it does not work for all cases. In particular, we have false results for the molar masses of double salts and crystalline hydrates.

I've found a reference to the proper structure: UIPAC Red Book. The '*' is supposed to be a '·' (mid dot) in reality, but I can parse on either. I just need to work out the least structurally damaging way to parse a prefix number for the constituent proportions. I will also add braces '{' and '}'.

Stuart

Re: Molecular Weight Function

Viktor Korobov wrote:

But it does not work for all cases. In particular, we have false results for the molar masses of double salts and crystalline hydrates.

Any better, Viktor?

Stuart

Re: Molecular Weight Function

Thank you Stuart. This version is the best.
But for some substances, the molar mass is calculated incorrectly.
For example:
Cupric Nitrate Pentahemihydrate Cu (NO3) 2 * 2.5H2O

Viktor

Re: Molecular Weight Function

Viktor Korobov wrote:

Thank you Stuart. This version is the best.
But for some substances, the molar mass is calculated incorrectly.
For example:
Cupric Nitrate Pentahemihydrate Cu (NO3) 2 * 2.5H2O

Are fractional (decimal or rational) proportions "legal" in a molecular formula for an addition compound, Viktor? I've had a quick look through the IUPAC Red Book and can't find an example of one or a rule that appears to permit them.

IR-4.2.4 Formulae of (formal) addition compounds

In the formulae of addition compounds and compounds which can formally be regarded as

such, including clathrates and multiple salts, a special format is used. The proportions of

constituents are indicated by arabic numerals preceding the formulae of the constituents, and

the formulae of the constituents are separated by a centre dot.

I read this to mean only integers, as the Red Book seems to be quite explicit about such things.

However, ... I've modified getNumber to handle decimal reals (but not with scientific or engineering notation exponents) and also included a stripspace function to remove extraneous spaces (I'm not sure they're allowed either?).

Stuart

Re: Molecular Weight Function

StuartBruff wrote:

Viktor Korobov wrote:

Thank you Stuart. This version is the best.
But for some substances, the molar mass is calculated incorrectly.
For example:
Cupric Nitrate Pentahemihydrate Cu (NO3) 2 * 2.5H2O

Are fractional (decimal or rational) proportions "legal" in a molecular formula for an addition compound, Viktor?


Yes, these formulas are "completely legal". See, for example, there:
http://www.americanelements.com/coper-nitrate-hemi-pentahydrate.html
http://jap.aip.org/resource/1/japiau/v39/i2/p1132_s1?isAuthorized=no
I think that the file collab - molecular weights 05.mcd can be viewed as the final version.

Thank you, Stuart. You did a great job!

Viktor

Message was edited by: Viktor Korobov ...I made small changes to a file for Valery's Mathcad Calcilation Server.

Viktor

Re: Molecular Weight Function

Ops! Another error:

Errors.GIF

Viktor

Viktor

Re: Molecular Weight Function

Viktor Korobov wrote:

Ops! Another error:

Errors.GIF

Viktor

OK. If you look at the table of molecules that I've included in my sheet, you will see several example of molecules comprised of a single element that have a molecular weight equal to the atomic weight. It struck me as strange and I took it to be just one of those conventions that chemists have, so I added a line in the result of mw to handle this case. I got the table from Corbin Consulting's website http://www.uswca.com/calcs/ions.htm and used it because it was the first reasonable size list of molecules and weights against which I could check mw. If it's not correct then simply remove the "list0,2...." program line from the first element of the result.

However, back to the fractional proportions ...

As I said, I'm a little confused because I can't find an authoritative reference that says this format is allowed (or, more likely, still allowed). It also presents me with the problem of knowing how to create the Hill Order representation, because I end up with fractional elements ... which seems a little bit odd outside of nuclear physics. Furthermore, when I did a search on the CAS number for Copper(II) nitrate hemi(pentahydrate) I got this site: http://www.chemicalbook.com/CASEN_19004-19-4.htm which gives a molecular formula of Cu2H10N4O17 and a molecular mass of 465.19, both of which seem to accord with integer proportions (eg, 2Cu(NO3)2 * 5H2O).

Stuart

Re: Molecular Weight Function

That's interesting. My local copy of the worksheet gives a correct Hill Order, but when I downloaded the version from the site, the column number at the start of the HillSort function is 1 instead of 0 .. I've also removed the '1' that occured with a single atom of an element. Corrected copy attached with version of single-element molecules that gives Viktor's expected result.

However, I still don't know how I should handle Hill Order representation when there are fractional proportions of addition compounds.

Stuart

Re: Molecular Weight Function

Just to pre-empt any requests, I've added a couple of functions that sort the list of elements in Hill Order and also converts it to a string

... in case anyone is looking for features, this is a classic example of where formatted strings would be useful to allow the molecular formula to be displayed with the atomic quantities as subscripts ... and without the quote marks!

Stuart

Message was edited by: StuartBruff 1432 hrs GMT I've replaced the worksheet ... forgot to remove the (9000) empty lines I'd added to make room for the Hill Order section. Oops.

Re: Molecular Weight Function

Nice sheet Stuart!

Changing the arrangement slightly seems to help avoid using the * (asterisk).

See attachment.

Norm

Re: Molecular Weight Function

Thanks, Norm. It's nice to see the mw function can handle the revised form.

However, I don't think Viktor is going to let me off that easily.

Stuart

Re: Molecular Weight Function

StuartBruff wrote:

Thanks, Norm. It's nice to see the mw function can handle the revised form.

However, I don't think Viktor is going to let me off that easily.

some hours later ...

Viktor Korobov wrote:

I agree that Stuart has created a wonderful document. But it does not work for all cases. In particular, we have false results for the molar masses of double salts and crystalline hydrates.

Told you so.

Stuart

Re: Molecular Weight Function

"...false results for the molar masses of double salts and crystalline hydrates."

Too much salt isn't good for you anyway....

At least there is a good start for another tool for our MathCad toolbox.

Best regards,

Norm

Re: Molecular Weight Function

Now on the MCS too - http://twt.mpei.ac.ru/MCS/Worksheets/Chem/MW.xmcd

See

MW1.png

PS

My name is OCHKOV.

Spelling: oxygen, carbon, hydrogen, potassium, oxygen and vanadium.

Announcements