-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathCKSSolid_Solutions.cpp
219 lines (190 loc) · 5.3 KB
/
CKSSolid_Solutions.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
// CKSSolid_Solutions.cpp : implementation file
//
// $Id$
//////////////////////////////////////////////////////////////////////
#include "stdafx.h"
#include "resource.h"
#include "CKSSolid_Solutions.h"
#ifdef _DEBUG
#undef THIS_FILE
static char BASED_CODE THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CCKSSolid_Solutions
IMPLEMENT_DYNAMIC(CCKSSolid_Solutions, baseCKSSolid_Solutions)
CCKSSolid_Solutions::CCKSSolid_Solutions(CWnd* pWndParent)
: baseCKSSolid_Solutions(IDS_PROPSHT_CAPTION11, pWndParent)
{
// Add all of the property pages here. Note that
// the order that they appear in here will be
// the order they appear in on screen. By default,
// the first page of the set is the active one.
// One way to make a different property page the
// active one is to call SetActivePage().
AddPage(&m_Page1);
AddPage(&m_Page2);
}
CCKSSolid_Solutions::~CCKSSolid_Solutions()
{
}
BEGIN_MESSAGE_MAP(CCKSSolid_Solutions, baseCKSSolid_Solutions)
//{{AFX_MSG_MAP(CCKSSolid_Solutions)
// NOTE - the ClassWizard will add and remove mapping macros here.
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CCKSSolid_Solutions message handlers
CString CCKSSolid_Solutions::GetString()
{
/*
Line 0: SOLID_SOLUTIONS 1 Two solid solutions
Line 1a: CaSrBaSO4 # greater than 2 components, ideal
Line 2a: -comp Anhydrite 1.500
Line 2b: -comp Celestite 0.05
Line 2c: -comp Barite 0.05
Line 1b: Ca(x)Mg(1-x)CO3 # Binary, nonideal
Line 3: -comp1 Calcite 0.097
Line 4: -comp2 Ca.5Mg.5CO3 0.003
Line 5: -temp 25.0
Line 6: -tempk 298.15
Line 7: -Gugg_nondim 5.08 1.90
Optional definitions of excess free-energy parameters for nonideal solid solutions:
Line 8: -Gugg_kj 12.593 4.70
Line 9: -activity_coefficients 24.05 1075. 0.0001 0.9999
Line 10: -distribution_coefficients .0483 1248. .0001 .9999
Line 11: -miscibility_gap 0.0428 0.9991
Line 12: -spinodal_gap 0.2746 0.9483
Line 13: -critical_point 0.6761 925.51
Line 14: -alyotropic_point 0.5768 -8.363
Line 15: -Thompson 17.303 7.883
Line 16: -Margules -0.62 7.6
*/
CString strLines;
CString strFormat;
// Line 0
strLines = GetLineZero(CKeyword::K_SOLID_SOLUTIONS);
std::list<CS_S>::const_iterator s_sIter = m_Page1.m_listS_S.begin();
for ( ; s_sIter != m_Page1.m_listS_S.end(); ++s_sIter)
{
// Line 1a
strFormat.Format(_T("%s%4c%s"),
(LPCTSTR)s_strNewLine,
_T(' '),
(LPCTSTR)(*s_sIter).m_strName
);
strLines += strFormat;
// Line 2
std::list<CS_S_Comp>::const_iterator compIter = (*s_sIter).m_listComp.begin();
for ( ; compIter != (*s_sIter).m_listComp.end(); ++compIter)
{
strFormat.Format(_T("%s%8c-comp %s %.*g"),
(LPCTSTR)s_strNewLine,
_T(' '),
(LPCTSTR)(*compIter).m_strName,
LDBL_DIG,
(*compIter).m_ldMoles
);
strLines += strFormat;
}
}
s_sIter = m_Page2.m_listS_S.begin();
for ( ; s_sIter != m_Page2.m_listS_S.end(); ++s_sIter)
{
// Line 1b
strFormat.Format(_T("%s%4c%s"),
(LPCTSTR)s_strNewLine,
_T(' '),
(LPCTSTR)(*s_sIter).m_strName
);
strLines += strFormat;
// Line 3
std::list<CS_S_Comp>::const_iterator compIter = (*s_sIter).m_listComp.begin();
ASSERT( compIter != (*s_sIter).m_listComp.end() );
strFormat.Format(_T("%s%8c-comp1 %s %.*g"),
(LPCTSTR)s_strNewLine,
_T(' '),
(LPCTSTR)(*compIter).m_strName,
LDBL_DIG,
(*compIter).m_ldMoles
);
strLines += strFormat;
// Line 4
compIter++;
ASSERT( compIter != (*s_sIter).m_listComp.end() );
strFormat.Format(_T("%s%8c-comp2 %s %.*g"),
(LPCTSTR)s_strNewLine,
_T(' '),
(LPCTSTR)(*compIter).m_strName,
LDBL_DIG,
(*compIter).m_ldMoles
);
strLines += strFormat;
// Lines 5 and 6
strFormat.Format(_T("%s%8c-tempk %.*g"),
(LPCTSTR)s_strNewLine,
_T(' '),
DBL_DIG,
(*s_sIter).m_dTk
);
strLines += strFormat;
// Lines 7 - 16
std::map<enum CS_S::InputCase, CString>::const_iterator item = m_Page2.m_mapIC2String.find((*s_sIter).m_nInputCase);
ASSERT( item != m_Page2.m_mapIC2String.end() );
if ((*s_sIter).m_nInputCase == CS_S::IC_ACTIVITY_COEFFICIENTS
||
(*s_sIter).m_nInputCase == CS_S::IC_DISTRIBUTION_COEFFICIENTS)
{
strFormat.Format(_T("%s%8c%s %.*g %.*g %.*g %.*g"),
(LPCTSTR)s_strNewLine,
_T(' '),
(LPCTSTR)(*item).second,
LDBL_DIG,
(*s_sIter).m_arrldP[0],
LDBL_DIG,
(*s_sIter).m_arrldP[1],
LDBL_DIG,
(*s_sIter).m_arrldP[2],
LDBL_DIG,
(*s_sIter).m_arrldP[3]
);
strLines += strFormat;
}
else
{
strFormat.Format(_T("%s%8c%s %.*g %.*g"),
(LPCTSTR)s_strNewLine,
_T(' '),
(LPCTSTR)(*item).second,
LDBL_DIG,
(*s_sIter).m_arrldP[0],
LDBL_DIG,
(*s_sIter).m_arrldP[1]
);
strLines += strFormat;
}
}
return strLines + s_strNewLine;
}
void CCKSSolid_Solutions::Edit(CString &rStr)
{
try
{
PhreeqcI p(rStr);
p.GetData(this);
}
catch (...)
{
CString strResource;
strResource.LoadString(IDS_EXCEPTION_ACCESS_VIOLATION);
::MessageBox(NULL, strResource, _T("Unhandled Exception"), MB_OK|MB_ICONERROR);
}
}
INT_PTR CCKSSolid_Solutions::DoModal()
{
// Add your specialized code here and/or call the base class
if (this->m_Page1.m_listS_S.size() == 0 && this->m_Page2.m_listS_S.size() > 0)
{
this->SetActivePage(1);
}
return CCommonKeywordSheet::DoModal();
}