-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathCKSExchange.cpp
167 lines (147 loc) · 3.9 KB
/
CKSExchange.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
// CKSExchange.cpp : implementation file
//
// $Id$
//////////////////////////////////////////////////////////////////////
#include "stdafx.h"
#include "resource.h"
#include "CKSExchange.h"
#include "Util.h"
#ifdef _DEBUG
#undef THIS_FILE
static char BASED_CODE THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CCKSExchange
IMPLEMENT_DYNAMIC(CCKSExchange, baseCKSExchange)
CCKSExchange::CCKSExchange(CWnd* pWndParent, CTreeCtrlNode simNode)
: baseCKSExchange(IDS_PROPSHT_CAPTION6, pWndParent)
, m_ranges(simNode, true)
, m_strNumFormat(_T("%d"))
, m_bSolution_equilibria(false)
, m_nEquilSolutionNum(N_NONE)
, m_bPitzer_exchange_gammas(true)
{
std::set<CDBRange> setSolutions;
m_strNumFormat = CUtil::CreateRange(m_setSolutions, m_ranges[CKeyword::K_SOLUTION]);
// 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);
AddPage(&m_Page3);
}
CCKSExchange::~CCKSExchange()
{
}
BEGIN_MESSAGE_MAP(CCKSExchange, baseCKSExchange)
//{{AFX_MSG_MAP(CCKSExchange)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CCKSExchange message handlers
CString CCKSExchange::GetString()
{
/*
Line 0: EXCHANGE 10 Measured exchange composition
Line 1a: CaX2 0.3
Line 1b: MgX2 0.2
Line 1c: NaX 0.5
Line 2a: CaY2 Ca-Montmorillonite equilibrium_phase 0.165
Line 2b: NaZ Kinetic_clay kinetic_reactant 0.1
Line 3: -equilibrate with solution 1
*/
CString strLines;
CString strFormat;
// Line 0
strLines = GetLineZero(CKeyword::K_EXCHANGE);
// Line 1
std::list<CExchComp>::const_iterator const_iter = m_Page1.m_listExchComp.begin();
for ( ; const_iter != m_Page1.m_listExchComp.end(); ++const_iter)
{
strFormat.Format(_T("%s%4c%-7s %.*g"),
(LPCTSTR)s_strNewLine,
_T(' '),
(LPCTSTR)(*const_iter).m_strFormula,
LDBL_DIG,
(*const_iter).m_ldMoles
);
strFormat.TrimRight();
strLines += strFormat;
}
// Line 2a
const_iter = m_Page2.m_listExchComp.begin();
for ( ; const_iter != m_Page2.m_listExchComp.end(); ++const_iter)
{
strFormat.Format(_T("%s%4c%-7s %-20s equilibrium_phase %.*g"),
(LPCTSTR)s_strNewLine,
_T(' '),
(LPCTSTR)(*const_iter).m_strFormula,
(LPCTSTR)(*const_iter).m_strPhase_name,
DBL_DIG,
(*const_iter).m_dPhase_proportion
);
strFormat.TrimRight();
strLines += strFormat;
}
// Line 2b
const_iter = m_Page3.m_listExchComp.begin();
for ( ; const_iter != m_Page3.m_listExchComp.end(); ++const_iter)
{
strFormat.Format(_T("%s%4c%-7s %-20s kinetic_reactant %.*g"),
(LPCTSTR)s_strNewLine,
_T(' '),
(LPCTSTR)(*const_iter).m_strFormula,
(LPCTSTR)(*const_iter).m_strRate_name,
DBL_DIG,
(*const_iter).m_dPhase_proportion
);
strFormat.TrimRight();
strLines += strFormat;
}
// Line 3
if (m_bSolution_equilibria)
{
ASSERT(m_nEquilSolutionNum != N_NONE);
strFormat.Format(_T("%s%4c-equilibrate with solution %d"),
(LPCTSTR)s_strNewLine,
_T(' '),
m_nEquilSolutionNum
);
strLines += strFormat;
}
// -pitzer_exchange_gammas (m_bPitzer_exchange_gammas)
if (m_bPitzer_exchange_gammas)
{
strFormat.Format(_T("%s%4c-pitzer_exchange_gammas true"),
(LPCTSTR)s_strNewLine,
_T(' ')
);
strLines += strFormat;
}
else
{
strFormat.Format(_T("%s%4c-pitzer_exchange_gammas false"),
(LPCTSTR)s_strNewLine,
_T(' ')
);
strLines += strFormat;
}
return strLines + s_strNewLine;
}
void CCKSExchange::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);
}
}