Molecular Modeling Software
リビジョン | 690fd4146d717de6c842863a18a0743b8e6afbdd (tree) |
---|---|
日時 | 2014-03-25 09:09:17 |
作者 | toshinagata1964 <toshinagata1964@a2be...> |
コミッター | toshinagata1964 |
Document figures in Step 11 are updated
git-svn-id: svn+ssh://svn.sourceforge.jp/svnroot/molby/trunk@506 a2be9bc6-48de-4e38-9406-05402d4bc13c
@@ -2012,7 +2012,7 @@ The "32" here is not a number but a string, because it is surrounded by quotatio | ||
2012 | 2012 | </p> |
2013 | 2013 | <p><img src="../etc/ruby_02.png" /></p> |
2014 | 2014 | <p> |
2015 | -Molby complains with this error dialog. It says "in '+': can't convert Fixnum into String," which means the integer 32 cannot be added to a string "C". Such kind of "type mismatch" error occurs very often, so please get used to it and learn how to fix it. | |
2015 | +Molby complains with this error dialog. It says "no implicit conversion of Fixnum into String," which means the integer 32 cannot be added to a string "C". Such kind of "type mismatch" error occurs very often, so please get used to it and learn how to fix it. | |
2016 | 2016 | </p> |
2017 | 2017 | <p> |
2018 | 2018 | Another useful feature of Ruby is an <i>Array</i>, which is an ordered collection of other Ruby objects. An array is expressed by comma-separated values surrounded by a pair of brackets. |
@@ -2220,9 +2220,25 @@ The last example generates a model of carbon nanotube with any chirality and len | ||
2220 | 2220 | <p class="code"><span class="comment"># Create a model of carbon nanotube |
2221 | 2221 | # Requires Molby</span> |
2222 | 2222 | r = 1.42 <span class="comment"># The C-C bond length</span> |
2223 | -n = 10 <span class="comment"># The chirality index</span> | |
2223 | +n = 10 <span class="comment"># The default chirality index</span> | |
2224 | 2224 | m = 5 <span class="comment"># (ibid)</span> |
2225 | -aspect = 5.0 <span class="comment"># The aspect ratio (length / diameter)</span> | |
2225 | +aspect = 5.0 <span class="comment"># The default aspect ratio (length / diameter)</span> | |
2226 | + | |
2227 | +# Dialog to ask the chirality index and the aspect ratio | |
2228 | +h = Dialog.run("Create Carbon Nanotube") { | |
2229 | + layout(3, | |
2230 | + item(:text, :title=>"Chirality Index"), | |
2231 | + item(:textfield, :width=>80, :tag=>"n", :value=>n.to_s), | |
2232 | + item(:textfield, :width=>80, :tag=>"m", :value=>m.to_s), | |
2233 | + item(:text, :title=>"Aspect Ratio"), | |
2234 | + item(:textfield, :width=>160, :tag=>"aspect", :value=>sprintf("%.1f", aspect)), | |
2235 | + -1) | |
2236 | +} | |
2237 | + | |
2238 | +exit if h[:status] != 0 | |
2239 | +aspect = h["aspect"].to_f | |
2240 | +n = h["n"].to_i | |
2241 | +m = h["m"].to_i | |
2226 | 2242 | |
2227 | 2243 | k = aspect / (PI * sqrt(3.0)) |
2228 | 2244 | points = [] |
@@ -2257,7 +2273,7 @@ mol.guess_bonds | ||
2257 | 2273 | mol2 = Molecule.open |
2258 | 2274 | mol2.add(mol) |
2259 | 2275 | </p> |
2260 | -<p><img src="../etc/ruby_07.png" /><img src="../etc/ruby_08.png" /></p> | |
2276 | +<p><img style="vertical-align: top;" src="../etc/ruby_07.png" /><img src="../etc/ruby_08.png" /></p> | |
2261 | 2277 | |
2262 | 2278 | <h2>5. Where to Go from Here</h2> |
2263 | 2279 | <p> |
@@ -2316,7 +2332,7 @@ Ruby インタプリタが "1+2" を計算し、答え (3) を次の行に表示 | ||
2316 | 2332 | </p> |
2317 | 2333 | <p><img src="../etc/ruby_02.png" /></p> |
2318 | 2334 | <p> |
2319 | -Molby はエラーメッセージ "in '+': can't convert Fixnum into String" を表示します。これは、「整数」32 を「文字列」"C" に足すことはできないことを意味しています。このような「型が違う」エラーはとてもよく起きるので、どのように直せばいいかをよく理解しておいてください。 | |
2335 | +Molby はエラーメッセージ "no implicit conversion of Fixnum into String" を表示します。これは、「整数」32 を「文字列」"C" に足すことはできないことを意味しています。このような「型が違う」エラーはとてもよく起きるので、どのように直せばいいかをよく理解しておいてください。 | |
2320 | 2336 | </p> |
2321 | 2337 | <p> |
2322 | 2338 | Ruby のもう1つの便利な機能は「配列」<i>(Array)</i> です。これは、他の Ruby オブジェクトを順番に並べたものです。配列は、値をコンマで区切って角括弧 [] で囲むことで表します。 |
@@ -2524,9 +2540,25 @@ fp.close <span class="comment"># We are done with this file | ||
2524 | 2540 | <p class="code"><span class="comment"># Create a model of carbon nanotube |
2525 | 2541 | # Requires Molby</span> |
2526 | 2542 | r = 1.42 <span class="comment"># The C-C bond length</span> |
2527 | -n = 10 <span class="comment"># The chirality index</span> | |
2543 | +n = 10 <span class="comment"># The default chirality index</span> | |
2528 | 2544 | m = 5 <span class="comment"># (ibid)</span> |
2529 | -aspect = 5.0 <span class="comment"># The aspect ratio (length / diameter)</span> | |
2545 | +aspect = 5.0 <span class="comment"># The default aspect ratio (length / diameter)</span> | |
2546 | + | |
2547 | +# Dialog to ask the chirality index and the aspect ratio | |
2548 | +h = Dialog.run("Create Carbon Nanotube") { | |
2549 | + layout(3, | |
2550 | + item(:text, :title=>"Chirality Index"), | |
2551 | + item(:textfield, :width=>80, :tag=>"n", :value=>n.to_s), | |
2552 | + item(:textfield, :width=>80, :tag=>"m", :value=>m.to_s), | |
2553 | + item(:text, :title=>"Aspect Ratio"), | |
2554 | + item(:textfield, :width=>160, :tag=>"aspect", :value=>sprintf("%.1f", aspect)), | |
2555 | + -1) | |
2556 | +} | |
2557 | + | |
2558 | +exit if h[:status] != 0 | |
2559 | +aspect = h["aspect"].to_f | |
2560 | +n = h["n"].to_i | |
2561 | +m = h["m"].to_i | |
2530 | 2562 | |
2531 | 2563 | k = aspect / (PI * sqrt(3.0)) |
2532 | 2564 | points = [] |
@@ -2561,7 +2593,7 @@ mol.guess_bonds | ||
2561 | 2593 | mol2 = Molecule.open |
2562 | 2594 | mol2.add(mol) |
2563 | 2595 | </p> |
2564 | -<p><img src="../etc/ruby_07.png" /><img src="../etc/ruby_08.png" /></p> | |
2596 | +<p><img style="vertical-align: top;" src="../etc/ruby_07.png" /><img src="../etc/ruby_08.png" /></p> | |
2565 | 2597 | |
2566 | 2598 | <h2>5. 次に学ぶべきこと</h2> |
2567 | 2599 | <p> |