smaerd
International Hazard
Posts: 1262
Registered: 23-1-2010
Member Is Offline
Mood: hmm...
|
|
I'm Writing a Chemistry Program(Input Please :))
Hi guys. I am currently writing a chemistry application. I figured I'd show the bare-bones stuff I have done so far and more importantly ask for some
input.
Obviously my drawing program is more 'rough' than tools such as Marvin Sketch that automatically groups the hydrogens on oxygens, hides carbons etc.
So my layout may be considered a hindrance to some.
Aside from drawing, and the obvious tools such as molar mass calculations(already programmed just not shown), etc, what else would be useful? I can do
3-D programming and could include a 3-D display of the drawn molecules(space-filling etc). Would things like lewis structure/vsepr, molecular orbital
diagrams for bonds, be considered an asset, or just something one might use rarely? How about bond length calculations? Any other ideas?
I'm writing it in C# in GTK on a linux OS. I am not using custom controls or anything in hopes of possibly porting it to Java for multi-platform and
on-line accessibility.
Any input would be appreciated.
I know this sounds crazy but I would like to eventually try to set it up to run reactions/predictions of reactions using some sort of 'reaction
language'. So user's could 'program'/download 'reactions' then try running them. I don't know how realistic this would be in all actuality, but its an
idea floating about.
If I do go 3-D with a viewer I was considering programming orbitals to be shown on highlighted bonds(probably not whole molecules due to graphics car
limitations and/or depth of graphics programming).
thanks for stopping through.
[Edited on 12-1-2011 by smaerd]
|
|
crazedguy
Hazard to Others
Posts: 143
Registered: 12-11-2010
Member Is Offline
Mood: You can't fix stupid
|
|
Well I definitely think this is a very cool idea, something to think about would be either to put in the options a full periodic table with weights
and electrons, or even a link to something like that would help someone new to chemistry.
[Edited on 12-1-2011 by crazedguy]
|
|
smaerd
International Hazard
Posts: 1262
Registered: 23-1-2010
Member Is Offline
Mood: hmm...
|
|
Ooo good call. Yes the periodic table right now is only brought up when the user clicks 'select other element' The image on currently is just a quick
'sketch'. So I can add plenty more to it and information would be a really good idea. I'll take that one to heart.
Thank you.
|
|
hkparker
National Hazard
Posts: 601
Registered: 15-10-2010
Location: California, United States
Member Is Offline
Mood: No Mood
|
|
Great work! Ill let you know if I have any input, none atm, but cool stuff, id like to see it when its finished
My YouTube Channel
"Nothing is too wonderful to be true if it be consistent with the laws of nature." -Michael Faraday
|
|
jokull
National Hazard
Posts: 506
Registered: 22-2-2006
Location: Everywhere
Member Is Offline
Mood: Ice glassed
|
|
Hi there!
Cool work.
I have a question: how easy is for your code to handle valence for N and P when used as heteroatoms?
|
|
smaerd
International Hazard
Posts: 1262
Registered: 23-1-2010
Member Is Offline
Mood: hmm...
|
|
Ah that's a really good question.
Right now this is in the bare-bones construction phase so any amount of bonds can be drawn amongst any amount of atoms whether or not its a feasible
operation. That is one of the hurdles coming up in the near future.
So your question is, how difficult would it be to program a user say replacing a carbon in benzene with say a nitrogen and making pyridine? I don't
think Nitrogen will be a big issue in that particular instance 4 bonds and 2 lone pairs. Handling charges is something I still need to add, for
example, if nitrogen were divalent as in NH2 it would be a negative until the user added say another hydrogen, and then adding another hydrogen it
would be positive.
The idea here is this, when an element is being replace in a compound you have a loop(for loop) that checks the bonds the previous atom had to see how
the charge is affected. The problem in the above example is that the extra hydrogen attached to the carbon, which would change the charge of the
nitrogen. So I would probably have the program keep the hydrogen but change the charge on the nitrogen(to a positive). The user then would have to be
clever enough to realize this is not pyridine until the hydrogen is selected and removed... Hmm maybe I'll be able to handle instances like this when
I get to it by removing the hydrogen(as marvin sketch would do/does).
I would have completely forgot about this case though without your post so thank you.
[Edited on 12-1-2011 by smaerd]
|
|
TheOrbit
Hazard to Self
Posts: 59
Registered: 4-4-2009
Location: deepth point of a black hole
Member Is Offline
Mood: manic bipolar science dis/order
|
|
it's looks as a nice try
|
|
aonomus
Hazard to Others
Posts: 361
Registered: 18-10-2009
Location: Toronto, Canada
Member Is Offline
Mood: Refluxing
|
|
To be succinct, take the feature set of chemsketch, add in the sane ability to snap to grid and snap to angle (and auto-cleanup of structures) of
chemdraw, and make the free, multiplatform program that you are talking about.
|
|
smaerd
International Hazard
Posts: 1262
Registered: 23-1-2010
Member Is Offline
Mood: hmm...
|
|
Snap to grid probably won't happen. I don't plan on basing it all on a grid system, that's a lot of work for one person(theres a reason why chemdraw
can cost from $380-$2,000 per year). Though that does bring up an interesting possibility. Maybe if I end up with more time.
Snap to angle? I'll look into it I was thinking about how to work with angles
intuitively, its a tricky concept. I was thinking about a wheel type window where the user can click the specified angle as well as including a
text-box input where it could be typed in.
I was thinking about alignment stuff today and fixing all drawn bond-lengths to a specific pixel length(specified by the user). So you can draw really
sloppy structures and have it fixed it on the fly. The hardest part is probably setting up decent drawing controls, because it has to be simple, but
somewhat efficient(not have the user click 10 times to draw a couple atoms and a bond).
How they do their clean structure though is beyond me I'll have to figure that out when I get there I suppose.
Thanks for the input I'll see what I can do. Yes this will be free when/if it is completed. I'd make it open source but sadly I think my code is too
yucky for most people to understand(even though I've been doing my best to make it manageable).
|
|
not_important
International Hazard
Posts: 3873
Registered: 21-7-2006
Member Is Offline
Mood: No Mood
|
|
You might want to look at Dia, http://live.gnome.org/Dia , perhaps use it as a basis for the drawing section. Under GPL, easy to get the sources. Uses XML to store drawing
data, can export to several common vector image formats.
I'd avoid using pixels as a length basis, that can vary so much from machine to machine or even if you change screen resolution. Better to treat it
as vectors, allow selection of image size in real world units such as cm, and scale during display drawing.
|
|
aonomus
Hazard to Others
Posts: 361
Registered: 18-10-2009
Location: Toronto, Canada
Member Is Offline
Mood: Refluxing
|
|
If you treat the entire canvas as a coordinate system and not by pixels, you can redraw the canvas by zoom level and scaling the vectors. Angles can
be determined by simple trig, as can determining target coordinates when provided a angle. Storing each atom as XML might be a bulky way to store
data, however its a much more open and (pardon the butchering of the word) parse-able to other vector graphics formats internally like SVG.
Start with a good core for the handling of coordinates and input method, add on features after. If I can't draw a clean looking organic structure
quickly, then I'm not using it over other methods like chemdraw.
|
|
smaerd
International Hazard
Posts: 1262
Registered: 23-1-2010
Member Is Offline
Mood: hmm...
|
|
Thank you for your input. Yea pixels are half-ass.
Good thing I already have a vector class written . I am currently using them to
test if the user's mouse is inside of a bond(rotated rectangle). Hmm I could get the user's screen size perhaps, transfer the window space to the
screen space(inches->centimeters), then transfer the drawing space to the window space? So position the objects based on them ex: distance between
each atom setting = 1cm, if that's what you guys mean?
Ahhh! I see what you guys mean by "snap to grid" now, not necessarily that there is a 'drawn-grid' but rather that there is scalable units for which
objects can be placed on. So instead of changing the bond length by pixels, 'zoom'. I dig it. Yea I'll see what I can do.
I couldn't physically draw a grid though using the current set-up. Using a drawingarea("widget") the 'refresh'/redraw speed will be drastically slowed
especially during commands such as dragging many parts of a 'bulky' molecule. Unless of course I write a bunch of custom control's, but as stated
above the goal is to use simple drawing commands so it is easily ported to another language and perhaps platform. As much as I'd love to sit down for
a year or two and write a commercial application, I'm a student and this is mostly for fun. I understand if it won't replace your professional needs,
I'm still gonna try my best to make it a decent tool.
I am using XML currently for periodic table information, and was already considering it for saving/loading because its so simple and as mentioned
easily ported to other formats(in many cases) even though it may be sinfully bulky.
DIA looks beautiful though I don't think it would be supported under C#. It's something to keep in mind if I feel like completely starting from
scratch(again).
[Edited on 13-1-2011 by smaerd]
|
|
turd
National Hazard
Posts: 800
Registered: 5-3-2006
Member Is Offline
Mood: No Mood
|
|
Quote: | As much as I'd love to sit down for a year or two and write a commercial application, I'm a student and this is mostly for fun. I understand if it
won't replace your professional needs, I'm still gonna try my best to make it a decent tool. | As with many
programming projects, the gained insights will far outweigh the invested work, so the end result is not even that important. Some major topics will be
analytical geometry, linear algebra and of course graph theory. These are some of the most intense studied fields in computer sciences, btw, so it's
probably not worth reinventing the wheel. Algorithms like finding cycles in a graph (which will be necessary to identify aromatics) are well
documented. If you were doing it in C++ I'd recommend to look at the Boost Graph Library (http://www.boost.org/doc/libs/1_42_0/libs/graph/doc/index.ht...), but I guess these algorithm are available for C# as well.
Quote: | Good thing I already have a vector class written . I am currently using them to
test if the user's mouse is inside of a bond(rotated rectangle). Hmm I could get the user's screen size perhaps, transfer the window space to the
screen space(inches->centimeters), then transfer the drawing space to the window space? So position the objects based on them ex: distance between
each atom setting = 1cm, if that's what you guys mean? |
Well, as a chemist, you should probably work internally with Å (or, if you have a SI fetish, with pm). Then you can draw atoms using their
(effective) ionic radii or for example at 50% size of their ionic radii. By probing the screen size in pixels and the screen resolution in DPI you can
then let the user give the zoom level as "1 Å corresponds to 1 cm".
Typically you will cook all the transformations from local coordinate system to screen coordinate system into one final matrix. This will allow you to
also do rotations, projections, etc.
|
|