Turn on suggestions

Auto-suggest helps you quickly narrow down your search results by suggesting possible matches as you type.

Showing results for

Auto-suggest helps you quickly narrow down your search results by suggesting possible matches as you type.

Showing results for

- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Mute
- Printer Friendly Page

Jun 24, 2012
06:45 PM

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator

Jun 24, 2012
06:45 PM

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

26 REPLIES 26

Jun 25, 2012
04:18 AM

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator

Jun 25, 2012
04:18 AM

In Mathcad 15:

Jun 25, 2012
08:53 AM

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator

Jun 25, 2012
08:53 AM

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

Stuart

Jun 25, 2012
10:02 AM

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator

Jun 25, 2012
10:02 AM

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.

Viktor

Jun 25, 2012
10:26 AM

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator

Jun 25, 2012
10:26 AM

Viktor Korobov wrote:

Valery,

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

Yes, I will add this site:

Jun 25, 2012
08:24 PM

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator

Jun 25, 2012
08:24 PM

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

Jun 26, 2012
07:33 AM

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator

Jun 26, 2012
07:33 AM

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

Jun 26, 2012
08:33 AM

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator

Jun 26, 2012
08:33 AM

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

Cruel man Viktor

Viktor

Jun 26, 2012
12:59 PM

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator

Jun 26, 2012
12:59 PM

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

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

Jun 27, 2012
02:17 AM

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator

Jun 27, 2012
02:17 AM

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

Jun 27, 2012
04:19 AM

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator

Jun 27, 2012
04:19 AM

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

Jun 28, 2012
02:01 AM

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator

Jun 28, 2012
02:01 AM

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

Jun 28, 2012
01:54 PM

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator

Jun 28, 2012
01:54 PM

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

Jun 28, 2012
04:48 PM

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator

Jun 28, 2012
04:48 PM

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

Jun 29, 2012
02:14 AM

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator

Jun 29, 2012
02:14 AM

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.5H2OAre 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

Jun 29, 2012
05:56 AM

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator

Jun 29, 2012
05:56 AM

Ops! Another error:

Viktor

Viktor

Jun 29, 2012
10:23 AM

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator

Jun 29, 2012
10:23 AM

Viktor Korobov wrote:

Ops! Another error:

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 "list_{0,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

Jun 29, 2012
10:39 AM

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator

Jun 29, 2012
10:39 AM

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

Jun 28, 2012
08:46 AM

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator

Jun 28, 2012
08:46 AM

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

... i**n 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.

Jun 26, 2012
11:02 AM

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator

Jun 26, 2012
11:02 AM

Nice sheet Stuart!

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

See attachment.

Norm

Jun 26, 2012
12:57 PM

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator

Jun 26, 2012
12:57 PM

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

Jun 27, 2012
04:09 AM

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator

Jun 27, 2012
04:09 AM

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

Jun 27, 2012
08:58 AM

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator

Jun 27, 2012
08:58 AM

"...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

Aug 19, 2021
11:50 AM

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator

Aug 19, 2021
11:50 AM

Is your "molecular weight" subroutine available for Mathcad Prime 6? I have tried to convert it using the in Prime built-in converter but I cannot get it to work. The original file works great with Mathcad 15. Any advice you may be able to give is appreciated.

Aug 19, 2021
01:52 PM

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator

Aug 19, 2021
01:52 PM

The problem seems to be that Primes programming does not use shortcut evaluation of combined boolean expressions.

There are quite some utility functions of Stuart which do not work in Prime anymore. I only modified three comparisons in "getName" and "getNumber" which seems to suffice to get the sheet to work OK.

Prime6 sheet attached.

Aug 20, 2021
03:34 AM

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator

Aug 20, 2021
03:34 AM

Thank you very much for your quick help, Werner_E!

Jun 29, 2012
04:43 AM

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator

Jun 29, 2012
04:43 AM

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

See

PS

My name is OCHKOV.

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