source: src/main/java/agents/anac/y2015/agentBuyogV2/flanagan/physprop/IonicRadii.java

Last change on this file was 127, checked in by Wouter Pasman, 6 years ago

#41 ROLL BACK of rev.126 . So this version is equal to rev. 125

File size: 18.7 KB
Line 
1/*
2* Class IonicRadii
3*
4* Methods for returning the non-hydrated ionic radius
5* or the hydrated ionic radius of an entered ion
6*
7* Bare radii taken from:
8* Indiana University Molecular Structure Center, Retrieved on 1st November 2004 from the World Wide Web:
9* http://www.iumsc.indiana.edu/radii.html
10* Their source is:
11* Shannon,R.D. (1976) `Revised effective ionic radii in halides and chalcogenides', Acta Cryst. A32, 751.
12*
13* WRITTEN BY: Michael Thomas Flanagan
14*
15* DATE: November 2004
16* UPDATE: 22 May 2005, 11 December 2007
17*
18* DOCUMENTATION:
19* See Michael Thomas Flanagan's JAVA library on-line web page:
20* http://www.ee.ucl.ac.uk/~mflanaga/java/IonicRadii.html
21* http://www.ee.ucl.ac.uk/~mflanaga/java/
22*
23* Copyright (c) 2004 - 2008 Michael Thomas Flanagan
24* PERMISSION TO COPY:
25* Permission to use, copy and modify this software and its documentation for
26* NON-COMMERCIAL purposes is granted, without fee, provided that an acknowledgement
27* to the author, Michael Thomas Flanagan at www.ee.ucl.ac.uk/~mflanaga, appears in all copies.
28*
29* Dr Michael Thomas Flanagan makes no representations about the suitability
30* or fitness of the software for any or for a particular purpose.
31* Michael Thomas Flanagan shall not be liable for any damages suffered
32* as a result of using, modifying or distributing this software or its derivatives.
33*
34***************************************************************************************/
35
36package agents.anac.y2015.agentBuyogV2.flanagan.physprop;
37
38import javax.swing.*;
39
40public class IonicRadii{
41
42 // ion symbols for non-hydrated ion radii
43 private static String[] ions1 = {"Ag+", "Al+++", "Au+", "Au+++", "Ba++", "Be++", "Bi+++", "Ca++", "Cd++", "Ce+++", "Ce++++", "Co++ ls", "Co++ hs", "Co+++ ls", "Co+++ hs", "Cr++ ls", "Cr++ hs", "Cr+++", "Cs+", "Cu+", "Cu++", "Dy+++", "Er+++", "Eu++", "Eu+++", "Fe++ ls", "Fe++ hs", "Fe+++ ls", "Fe+++ hs", "Ga+++", "Gd+++", "Hf++++", "Hg+", "Hg++", "Ho+++", "In+++", "Ir+++", "K+", "La+++", "Li+", "Lu+++", "Mg++", "Mn++ ls", "Mn++ hs", "Mn+++ ls", "Mn+++ hs", "Mo+++", "Na+", "Nb+++", "Nd+++", "Ni++", "Pb++", "Pd++", "Pm+++", "Pr+++", "Pt++", "Rb+", "Rh+++", "Ru+++", "Sb+++", "Sc+++", "Sm+++", "Sr++", "Ta+++", "Tb+++", "Th++++", "Ti++", "Ti+++", "Ti++++", "Tl+", "Tl+++", "Tm+++", "U+++", "U++++", "V++", "V+++", "Y+++", "Yb++", "Yb+++", "Zn++", "Zr++++", "Br-", "Cl-", "F-", "H-", "I-", "O--", "S--", "Se--", "Te--", "OH-"};
44 private static String[] ions2 = {"Ag1+", "Al3+", "Au1+", "Au3+", "Ba2+", "Be2+", "Bi3+", "Ca2+", "Cd2+", "Ce3+", "Ce4+", "Co2+ ls", "Co2+ hs", "Co3+ ls", "Co3+ hs", "Cr2+ ls", "Cr2+ hs", "Cr3+", "Cs1+", "Cu1+", "Cu2+", "Dy3+", "Er3+", "Eu2+", "Eu3+", "Fe2+ ls", "Fe2+ hs", "Fe3+ ls", "Fe3+ hs", "Ga3+", "Gd3+", "Hf4+", "Hg1+", "Hg2+", "Ho3+", "In3+", "Ir3+", "K1+", "La3+", "Li1+", "Lu3+", "Mg2+", "Mn2+ ls", "Mn2+ hs", "Mn3+ ls", "Mn3+ hs", "Mo3+", "Na1+", "Nb3+", "Nd3+", "Ni2+", "Pb2+", "Pd2+", "Pm3+", "Pr3+", "Pt2+", "Rb1+", "Rh3+", "Ru3+", "Sb3+", "Sc3+", "Sm3+", "Sr2+", "Ta3+", "Tb3+", "Th4+", "Ti2+", "Ti3+", "Ti4+", "Tl1+", "Tl3+", "Tm3+", "U3+", "U4+", "V2+", "V3+", "Y3+", "Yb2+", "Yb3+", "Zn2+", "Zr4+", "Br1-", "Cl1-", "F1-", "H1-", "I1-", "O2-", "S2-", "Se2-", "Te2-", "OH1-"};
45 private static String[] ions3 = {"Ag+1", "Al+3", "Au+1", "Au+3", "Ba+2", "Be+2", "Bi+3", "Ca+2", "Cd+2", "Ce+3", "Ce+4", "Co+2 ls", "Co+2 hs", "Co+3 ls", "Co+3 hs", "Cr+2 ls", "Cr+2 hs", "Cr+3", "Cs+1", "Cu+1", "Cu+2", "Dy+3", "Er+3", "Eu+2", "Eu+3", "Fe+2 ls", "Fe+2 hs", "Fe+3 ls", "Fe+3 hs", "Ga+3", "Gd+3", "Hf+4", "Hg+1", "Hg+2", "Ho+3", "In+3", "Ir+3", "K+1", "La+3", "Li+1", "Lu+3", "Mg+2", "Mn+2 ls", "Mn+2 hs", "Mn+3 ls", "Mn+3 hs", "Mo+3", "Na+1", "Nb+3", "Nd+3", "Ni+2", "Pb+2", "Pd+2", "Pm+3", "Pr+3", "Pt+2", "Rb+1", "Rh+3", "Ru+3", "Sb+3", "Sc+3", "Sm+3", "Sr+2", "Ta+3", "Tb+3", "Th+4", "Ti+2", "Ti+3", "Ti+4", "Tl+1", "Tl+3", "Tm+3", "U+3", "U+4", "V+2", "V+3", "Y+3", "Yb+2", "Yb+3", "Zn+2", "Zr+4", "Br-1", "Cl-1", "F-1", "H-1", "I-1", "O-2", "S-2", "Se-2", "Te-2", "OH-1"};
46 private static String[] ions4 = {"Ag(+)", "Al(+++)", "Au(+)", "Au(+++)", "Ba(++)", "Be(++)", "Bi(+++)", "Ca(++)", "Cd(++)", "Ce(+++)", "Ce(++++)", "Co(++) ls", "Co(++) hs", "Co(+++) ls", "Co(+++) hs", "Cr(++) ls", "Cr(++) hs", "Cr(+++)", "Cs(+)", "Cu(+)", "Cu(++)", "Dy(+++)", "Er(+++)", "Eu(++)", "Eu(+++)", "Fe(++) ls", "Fe(++) hs", "Fe(+++) ls", "Fe(+++) hs", "Ga(+++)", "Gd(+++)", "Hf(++++)", "Hg(+)", "Hg(++)", "Ho(+++)", "In(+++)", "Ir(+++)", "K(+)", "La(+++)", "Li(+)", "Lu(+++)", "Mg(++)", "Mn(++) ls", "Mn(++) hs", "Mn(+++) ls", "Mn(+++) hs", "Mo(+++)", "Na(+)", "Nb(+++)", "Nd(+++)", "Ni(++)", "Pb(++)", "Pd(++)", "Pm(+++)", "Pr(+++)", "Pt(++)", "Rb(+)", "Rh(+++)", "Ru(+++)", "Sb(+++)", "Sc(+++)", "Sm(+++)", "Sr(++)", "Ta(+++)", "Tb(+++)", "Th(++++)", "Ti(++)", "Ti(+++)", "Ti(++++)", "Tl(+)", "Tl(+++)", "Tm(+++)", "U(+++)", "U(++++)", "V(++)", "V(+++)", "Y(+++)", "Yb(++)", "Yb(+++)", "Zn(++)", "Zr(++++)", "Br(-)", "Cl(-)", "F(-)", "H(-)", "I(-)", "O(--)", "S(--)", "Se(--)", "Te(--)", "OH(-)"};
47 private static String[] ions5 = {"Ag(1+)", "Al(3+)", "Au(1+)", "Au(3+)", "Ba(2+)", "Be(2+)", "Bi(3+)", "Ca(2+)", "Cd(2+)", "Ce(3+)", "Ce(4+)", "Co(2+) ls", "Co(2+) hs", "Co(3+) ls", "Co(3+) hs", "Cr(2+) ls", "Cr(2+) hs", "Cr(3+)", "Cs(1+)", "Cu(1+)", "Cu(2+)", "Dy(3+)", "Er(3+)", "Eu(2+)", "Eu(3+)", "Fe(2+) ls", "Fe(2+) hs", "Fe(3+) ls", "Fe(3+) hs", "Ga(3+)", "Gd(3+)", "Hf(4+)", "Hg(1+)", "Hg(2+)", "Ho(3+)", "In(3+)", "Ir(3+)", "K(1+)", "La(3+)", "Li(1+)", "Lu(3+)", "Mg(2+)", "Mn(2+) ls", "Mn(2+) hs", "Mn(3+) ls", "Mn(3+) hs", "Mo(3+)", "Na(1+)", "Nb(3+)", "Nd(3+)", "Ni(2+)", "Pb(2+)", "Pd(2+)", "Pm(3+)", "Pr(3+)", "Pt(2+)", "Rb(1+)", "Rh(3+)", "Ru(3+)", "Sb(3+)", "Sc(3+)", "Sm(3+)", "Sr(2+)", "Ta(3+)", "Tb(3+)", "Th(4+)", "Ti(2+)", "Ti(3+)", "Ti(4+)", "Tl(1+)", "Tl(3+)", "Tm(3+)", "U(3+)", "U(4+)", "V(2+)", "V(3+)", "Y(3+)", "Yb(2+)", "Yb(3+)", "Zn(2+)", "Zr(4+)", "Br(1-)", "Cl(1-)", "F(1-)", "H(1-)", "I(1-)", "O(2-)", "S(2-)", "Se(2-)", "Te(2-)", "OH(1-)"};
48 private static String[] ions6 = {"Ag(+1)", "Al(+3)", "Au(+1)", "Au(+3)", "Ba(+2)", "Be(+2)", "Bi(+3)", "Ca(+2)", "Cd(+2)", "Ce(+3)", "Ce(+4)", "Co(+2) ls", "Co(+2) hs", "Co(+3) ls", "Co(+3) hs", "Cr(+2) ls", "Cr(+2) hs", "Cr(+3)", "Cs(+1)", "Cu(+1)", "Cu(+2)", "Dy(+3)", "Er(+3)", "Eu(+2)", "Eu(+3)", "Fe(+2) ls", "Fe(+2) hs", "Fe(+3) ls", "Fe(+3) hs", "Ga(+3)", "Gd(+3)", "Hf(+4)", "Hg(+1)", "Hg(+2)", "Ho(+3)", "In(+3)", "Ir(+3)", "K(+1)", "La(+3)", "Li(+1)", "Lu(+3)", "Mg(+2)", "Mn(+2) ls", "Mn(+2) hs", "Mn(+3) ls", "Mn(+3) hs", "Mo(+3)", "Na(+1)", "Nb(+3)", "Nd(+3)", "Ni(+2)", "Pb(+2)", "Pd(+2)", "Pm(+3)", "Pr(+3)", "Pt(+2)", "Rb(+1)", "Rh(+3)", "Ru(+3)", "Sb(+3)", "Sc(+3)", "Sm(+3)", "Sr(+2)", "Ta(+3)", "Tb(+3)", "Th(+4)", "Ti(+2)", "Ti(+3)", "Ti(+4)", "Tl(+1)", "Tl(+3)", "Tm(+3)", "U(+3)", "U(+4)", "V(+2)", "V(+3)", "Y(+3)", "Yb(+2)", "Yb(+3)", "Zn(+2)", "Zr(+4)", "Br(-1)", "Cl(-1)", "F(-1)", "H(-1)", "I(-1)", "O(-2)", "S(-2)", "Se(-2)", "Te(-2)", "OH(-1)"};
49
50 // spin state indicators
51 private static boolean[] spins = {false, false, false, false, false, false, false, false, false, false, false, true, true, true, true, true, true,false, false, false, false, false, false, false, false, true, true, true, true, false, false, false, false, false, false, false, false, false, false, false, false, false, true, true, true, true,false, false, false, false, false, false, false, false, false, false, false, false, false, false,false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false};
52
53 // charges
54 private static int[] ionCharge = {1, 3, 1, 3, 2, 2, 3, 2, 2, 3, 4, 2, 2, 3, 3, 2, 2, 3, 1, 1, 2, 3, 3, 2, 3, 2, 2, 3, 3, 3, 3, 4, 1, 2, 3, 3, 3, 1, 3, 1, 3, 2, 2, 2, 3, 3, 3, 1, 3, 3, 2, 2, 2, 3, 3, 2, 1, 3, 3, 3, 3, 3, 2, 3, 3, 4, 2, 3, 4, 1, 3, 3, 3, 4, 2, 3, 3, 2, 3, 2, 4, -1, -1, -1, -1, -1, -2, -2, -2, -2, -1};
55
56 // non-hydrated ionic radii (pm)
57 private static double radii[] = {129, 67.5, 151, 99, 149, 59, 117, 114, 109, 115, 101, 79, 88.5, 68.5, 75, 87, 94, 75.5, 181, 91, 87, 105.2, 103, 131, 108.7, 75, 92, 69, 78.5, 76, 107.8, 85, 133, 116, 104.1, 94, 82, 152, 117.2, 90, 100.1, 86, 81, 97, 72, 78.5, 83, 116, 86, 112.3, 83, 133, 100, 111, 113, 94, 166, 80.5, 82, 90, 88.5, 109.8, 132, 86, 106.3, 108, 100, 81, 74.5, 164, 102.5, 102, 116.5, 103 ,93, 78, 104, 116, 100.8, 88, 86, 167, 182, 119, 139, 206, 126, 170, 184, 207, 120};
58
59 // ion symbols for hydrated ion radii
60 private static String[] hydratedIons1 = {"Ag+", "Al+++", "Be++", "Ca++", "Cd++", "Cs+", "K+", "Li+", "Mg++", "Na+", "Pb++", "Rb+", "Tl+", "Zn++", "H30+", "NH4+", "Cl-", "Br-", "F-", "I-", "NO3-", "OH-"};
61 private static String[] hydratedIons2 = {"Ag1+", "Al3+", "Be2+", "Ca2+", "Cd2+", "Cs1+", "K1+", "Li1+", "Mg2+", "Na1+", "Pb2+", "Rb1+", "Tl1+", "Zn2+", "H301+", "NH41+", "Cl1-", "Br1-", "F1-", "I1-", "NO31-", "OH1-"};
62 private static String[] hydratedIons3 = {"Ag+1", "Al+3", "Be+2", "Ca+2", "Cd+2", "Cs+1", "K+1", "Li+1", "Mg+2", "Na+1", "Pb+2", "Rb+1", "Tl+1", "Zn+2", "H30+1", "NH4+1", "Cl-1", "Br-1", "F-1", "I-1", "NO3-1", "OH-1"};
63 private static String[] hydratedIons4 = {"Ag(+)", "Al(+++)", "Be(++)", "Ca(++)", "Cd(++)", "Cs(+)", "K(+)", "Li(+)", "Mg(++)", "Na(+)", "Pb(++)", "Rb(+)", "Tl(+)", "Zn(++)", "H30(+)", "NH4(+)", "Cl(-)", "Br(-)", "F(-)", "I(-)", "NO3(-)", "OH(-)"};
64 private static String[] hydratedIons5 = {"Ag(1+)", "Al(3+)", "Be(2+)", "Ca(2+)", "Cd(2+)", "Cs(1+)", "K(1+)", "Li(1+)", "Mg(2+)", "Na(1+)", "Pb(2+)", "Rb(1+)", "Tl(1+)", "Zn(2+)", "H30(1+)", "NH4(1+)", "Cl(1-)", "Br(1-)", "F(1-)", "I(1-)", "NO3(1-)", "OH(1-)"};
65 private static String[] hydratedIons6 = {"Ag(+1)", "Al(+3)", "Be(+2)", "Ca(+2)", "Cd(+2)", "Cs(+1)", "K(+1)", "Li(+1)", "Mg(+2)", "Na(+1)", "Pb(+2)", "Rb(+1)", "Tl(+1)", "Zn(+2)", "H30(+1)", "NH4(+1)", "Cl(-1)", "Br(-1)", "F(-1)", "I(-1)", "NO3(-1)", "OH(-1)"};
66
67 // hydated ionic radii (pm)
68 private static double hydratedRadii[] = {341.0, 480.0, 459.0, 412.0, 426.0, 329.0, 331.0, 382.0, 428.0, 358.0, 401.0, 329.0, 330.0, 430.0, 280.0, 331.0, 332.0, 332.0, 330.0, 352.0, 340.0, 300.0};
69
70 private static int nIons = 91; // number of ions listed for non-hydrated radii
71 private static int nHydratedIons = 22; // number of ions listed for hydrated radii
72
73 // variables used in methods
74 // String ion - symbol of current ion without spin indicator
75 // String fullIon - symbol of current ion with spin indicator if available
76 // String spin - spin value of current ion if option available
77 // boolean spinSet = true when spin state is set
78
79 // Method to return an ionic radius for ion with low and high spin states
80 public static double radius(String ion, String spin){
81 boolean spinSet = false;
82 spin = spin.trim();
83
84 if(spin.equals("ls") || spin.equals("low") || spin.equals("low spin") || spin.equals("LS")){
85 spin = "ls";
86 }
87 else{
88 if(spin.equals("hs") || spin.equals("high") || spin.equals("high spin") || spin.equals("HS")){
89 spin = "hs";
90 }
91 else{
92 throw new IllegalArgumentException("spin state must be entered as ls or hs not as " + spin);
93 }
94 }
95 spinSet = true;
96 ion = ion.trim();
97 String fullIon = ion + " " + spin;
98 return radiusCalc(fullIon, spinSet);
99 }
100
101 // Method to return an ionic radius - no spin state set
102 public static double radius(String ion){
103 boolean spinSet = false;
104 return radiusCalc(ion, spinSet);
105 }
106
107 // Private method to retrieve an ionic radius
108 private static double radiusCalc(String ion, boolean spinSet){
109 String fullIon = ion.trim();
110 if(!spinSet)ion = fullIon;
111
112 boolean test0 = true;
113 boolean test1 = false;
114 int ii = 0;
115 double radius = 0.0D;
116
117 // check entered ion against ion list
118 while(test0){
119 if(IonicRadii.compareBare(fullIon, ii)){
120 test0 = false;
121 test1 = true;
122 radius = IonicRadii.radii[ii]*1e-12;
123 }
124 else{
125 ii++;
126 if(ii>=IonicRadii.nIons)test0=false;
127 }
128 }
129
130 // check if hs or ls is needed and is missing
131 if(!test1 && !spinSet){
132 test0=true;
133 ii=0;
134 while(test0){
135 if(compareSubstringBare(ion, ii) && IonicRadii.spins[ii]){
136 test0 = false;
137 test1 = true;
138 boolean test2 = true;
139 String enqTitle = ion+" may be low spin or high spin";
140 Object[] options = { "low spin", "high spin" };
141 while(test2){
142 int opt = JOptionPane.showOptionDialog(null, "Click appropriate box", enqTitle, JOptionPane.YES_NO_CANCEL_OPTION, JOptionPane.QUESTION_MESSAGE,null, options, options[0]);
143
144 if(opt==0){
145 radius = IonicRadii.radii[ii]*1e-12;
146 test2 = false;
147 }
148 else{
149 if(opt==1){
150 radius = IonicRadii.radii[ii+1]*1e-12;
151 test2 = false;
152 }
153 else{
154 System.out.println("You must click either low spin or high spin");
155 }
156 }
157 }
158 }
159 else{
160 ii++;
161 if(ii>=IonicRadii.nIons)test0=false;
162 }
163 }
164 }
165
166 // check if hs or ls has been entered and is not appropriate to the ion entered
167 if(!test1){
168 if(spinSet){
169 test0 = true;
170 ii = 0;
171 while(test0){
172 if(IonicRadii.compareBare(ion, ii)){
173 test0 = false;
174 test1 = true;
175 radius = IonicRadii.radii[ii]*1e-12;
176 System.out.println(ion + " does not have low and high spin states listed");
177 System.out.println("Single availabe listed radius was used");
178 }
179 else{
180 ii++;
181 if(ii>=IonicRadii.nIons)test0=false;
182 }
183 }
184 }
185 }
186
187 // Abort if entered ion was not found in lists
188 if(!test1){
189 System.out.println("Class: IonicRadii\nMethod: radius\n" + fullIon + " was not found in the lists of non-hydrated radii");
190 System.out.println("0.0D returned");
191 }
192 spinSet = false;
193 return radius;
194 }
195
196 // Compares entered ion with all lists of ions for non-hydrated radii values
197 public static boolean compareBare(String ion, int ii){
198 boolean test = false;
199 if(ion.equals(IonicRadii.ions1[ii])||ion.equals(IonicRadii.ions2[ii])||ion.equals(IonicRadii.ions3[ii])||ion.equals(IonicRadii.ions4[ii])||ion.equals(IonicRadii.ions5[ii])||ion.equals(IonicRadii.ions6[ii])){
200 test = true;
201 }
202 return test;
203 }
204
205 // Compares entered ion as a substring, e.g. without ls or hs indicator, with all lists of ions for non-hydrated radii values
206 public static boolean compareSubstringBare(String ion, int ii){
207 boolean test = false;
208 if(IonicRadii.ions1[ii].indexOf(ion)>-1||IonicRadii.ions2[ii].indexOf(ion)>-1||IonicRadii.ions3[ii].indexOf(ion)>-1||IonicRadii.ions4[ii].indexOf(ion)>-1||IonicRadii.ions5[ii].indexOf(ion)>-1||IonicRadii.ions6[ii].indexOf(ion)>-1){
209 test = true;
210 }
211 return test;
212 }
213
214 // Method to return a hydrated ionic radius
215 public static double hydratedRadius(String ion){
216 ion = ion.trim();
217
218 boolean test0 = true;
219 boolean test1 = false;
220 int i = 0;
221 double radius = 0.0D;
222
223 // check entered ion against ion list
224 while(test0){
225 if(IonicRadii.compareHydrated(ion, i)){
226 test0 = false;
227 test1 = true;
228 radius = hydratedRadii[i]*1e-12;
229 }
230 else{
231 i++;
232 if(i>=nHydratedIons)test0=false;
233 }
234 }
235
236 // Abort if entered ion was not found in lists
237 if(!test1){
238 System.out.println("Class: IonicRadii\nMethod: hydratedRadius\n"+ion + " was not found in the lists of hydrated radii");
239 System.out.println("0.0D returned");
240 }
241
242 return radius;
243 }
244
245
246 // Compares entered ion with all lists of ions for hydrated radii values
247 public static boolean compareHydrated(String ion, int ii){
248 boolean test = false;
249 if(ion.equals(IonicRadii.hydratedIons1[ii])||ion.equals(IonicRadii.hydratedIons2[ii])||ion.equals(IonicRadii.hydratedIons3[ii])||ion.equals(IonicRadii.hydratedIons4[ii])||ion.equals(IonicRadii.hydratedIons5[ii])||ion.equals(IonicRadii.hydratedIons6[ii])){
250 test = true;
251 }
252 return test;
253 }
254
255 // Compares entered ion as a substring, e.g. without ls or hs indicator, with all lists of ions for hydrated radii values
256 public static boolean compareSubstringHydrated(String ion, int ii){
257 boolean test = false;
258 if(IonicRadii.hydratedIons1[ii].indexOf(ion)>-1||IonicRadii.hydratedIons2[ii].indexOf(ion)>-1||IonicRadii.hydratedIons3[ii].indexOf(ion)>-1||IonicRadii.hydratedIons4[ii].indexOf(ion)>-1||IonicRadii.hydratedIons5[ii].indexOf(ion)>-1||IonicRadii.hydratedIons6[ii].indexOf(ion)>-1){
259 test = true;
260 }
261 return test;
262 }
263
264 // Method to return the charge on the ion
265 public static int charge(String ion){
266 ion = ion.trim();
267
268 boolean test0 = true;
269 boolean test1 = false;
270 int i = 0;
271 int charge = 0;
272
273 // check entered ion against ion list
274 while(test0){
275 if(IonicRadii.compareBare(ion, i)){
276 test0 = false;
277 test1 = true;
278 charge = ionCharge[i];
279 }
280 else{
281 i++;
282 if(i>=nIons)test0=false;
283 }
284 }
285
286 // Abort if entered ion was not found in lists
287 if(!test1){
288 System.out.println("Class: IonicRadii\nMethod: charge\n"+ion + " was not found in the lists of non-hydrated ions");
289 System.out.println("0 returned");
290 }
291
292 return charge;
293 }
294}
295
296
297
298
299
Note: See TracBrowser for help on using the repository browser.