Page Menu
Home
c4science
Search
Configure Global Search
Log In
Files
F92317491
eqcurve_extractor.cpp
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Subscribers
None
File Metadata
Details
File Info
Storage
Attached
Created
Tue, Nov 19, 08:58
Size
1 KB
Mime Type
text/x-c
Expires
Thu, Nov 21, 08:58 (2 d)
Engine
blob
Format
Raw Data
Handle
22421732
Attached To
rSPECMICP SpecMiCP / ReactMiCP
eqcurve_extractor.cpp
View Options
#include "eqcurve_extractor.hpp"
#include <iostream>
namespace
specmicp
{
namespace
reactmicp
{
namespace
eqcurve
{
index_t
EquilibriumCurveExtractor
::
find_point
(
scalar_t
x
)
{
index_t
index
;
const
index_t
size
=
m_eqcurve
.
rows
();
index_t
lower_index
=
0
;
index_t
upper_index
=
size
+
1
;
while
(
upper_index
-
lower_index
>
1
)
{
index
=
(
upper_index
+
lower_index
)
/
2
;
if
((
x
>=
xs_offset
(
index
))
==
is_increasing
())
lower_index
=
index
;
else
upper_index
=
index
;
}
if
(
x
==
xs_offset
(
1
))
index
=
0
;
else
if
(
x
==
xs_offset
(
size
))
index
=
size
-
1
;
else
index
=
std
::
max
((
specmicp
::
index_t
)
0
,
lower_index
-
1
);
return
index
;
}
scalar_t
EquilibriumCurveExtractor
::
interpolate
(
index_t
index
,
scalar_t
x
,
index_t
col
)
{
// limit
if
(
is_increasing
())
{
if
(
x
<=
m_eqcurve
(
first
(),
0
))
return
m_eqcurve
(
first
(),
col
);
else
if
(
x
>=
m_eqcurve
(
last
(),
0
))
return
m_eqcurve
(
last
(),
col
);
}
else
{
if
(
x
>=
m_eqcurve
(
first
(),
0
))
return
m_eqcurve
(
first
(),
col
);
else
if
(
x
<=
m_eqcurve
(
last
(),
0
))
return
m_eqcurve
(
last
(),
col
);
}
scalar_t
y
;
const
scalar_t
diff
=
slope
(
index
,
col
);
y
=
m_eqcurve
(
index
,
col
)
+
diff
*
(
m_eqcurve
(
index
+
1
,
0
)
-
x
);
return
y
;
}
scalar_t
EquilibriumCurveExtractor
::
slope
(
index_t
index
,
index_t
col
)
{
if
(
index
==
last
())
return
(
m_eqcurve
(
index
-
1
,
col
)
-
m_eqcurve
(
index
,
col
))
/
(
m_eqcurve
(
index
-
1
,
0
)
-
m_eqcurve
(
index
,
0
));
return
(
m_eqcurve
(
index
+
1
,
col
)
-
m_eqcurve
(
index
,
col
))
/
(
m_eqcurve
(
index
+
1
,
0
)
-
m_eqcurve
(
index
,
0
));
}
}
// end namespace eqcurve
}
// end namespace reactmicp
}
// end namespace specmicp
Event Timeline
Log In to Comment