commit 30bd8591a0a2147c306d3ac6eb4e104fe4e43661
parent dd6e4a6192cacf70f232a97a5429e15a26bdc7cd
Author: Vincent Forest <vincent.forest@meso-star.com>
Date: Tue, 12 Jan 2021 14:56:22 +0100
Add the dp & np soot parameter
"np" means for number of primary particles per aggregate and "dp" means
for primary particles diameter.
Diffstat:
5 files changed, 36 insertions(+), 30 deletions(-)
diff --git a/doc/atrtp b/doc/atrtp
@@ -9,7 +9,7 @@
<thermo-props> ::= <thermo-prop>
[ <thermo-prop ... ]
-<therm-prop> ::= <pressure> <temperature> <xH2O> <xCO2> <xCO> <fv-soot>
+<therm-prop> ::= <pressure> <temperature> <xH2O> <xCO2> <xCO> <vf-soot> <np-soot> <dp-soot>
<pressure> ::= <double> # Pressure in Pa
<temperature> ::= <double> # Temperature in K
@@ -17,4 +17,6 @@
<xCO2> ::= <double> # Molar fraction of CO2 in mol(CO2)/mol(mixture)
<xCO> ::= <double> # Molar fraction of CO in mol(CO)/mol(mixture)
<vf-soot> ::= <double> # Volumic fraction of soot in m^3(soot)/ m^3
+<np-soot> ::= <double> # Number of primary particles per agregate
+<dp-soot> ::= <double> # Primary particles diameter in nm
diff --git a/src/atrtp.c b/src/atrtp.c
@@ -34,7 +34,7 @@ reset_atrtp(struct atrtp* atrtp)
{
ASSERT(atrtp);
atrtp->pagesize = 0;
- atrtp->ncells = 0;
+ atrtp->nnodes = 0;
if(atrtp->props) munmap(atrtp->props, atrtp->map_len);
atrtp->props = NULL;
atrtp->map_len = 0;
@@ -59,7 +59,7 @@ load_stream(struct atrtp* atrtp, FILE* stream, const char* stream_name)
} \
} (void)0
READ(&atrtp->pagesize, 1, "page size");
- READ(&atrtp->ncells, 1, "number of cells");
+ READ(&atrtp->nnodes, 1, "number of nodes");
#undef READ
if(!IS_ALIGNED(atrtp->pagesize, atrtp->pagesize_os)) {
@@ -72,7 +72,7 @@ load_stream(struct atrtp* atrtp, FILE* stream, const char* stream_name)
}
/* Compute the length in bytes of the data to map */
- atrtp->map_len = atrtp->ncells * sizeof(double[ATRTP_COUNT__]);
+ atrtp->map_len = atrtp->nnodes * sizeof(double[ATRTP_COUNT__]);
atrtp->map_len = ALIGN_SIZE(atrtp->map_len, (size_t)atrtp->pagesize);
/* Find the offsets of the positions/indices data into the stream */
@@ -233,7 +233,7 @@ atrtp_get_desc(const struct atrtp* atrtp, struct atrtp_desc* desc)
{
if(!atrtp || !desc) return RES_BAD_ARG;
desc->properties = atrtp->props;
- desc->ncells = (size_t)atrtp->ncells;
+ desc->nnodes = (size_t)atrtp->nnodes;
return RES_OK;
}
diff --git a/src/atrtp.h b/src/atrtp.h
@@ -43,13 +43,15 @@ enum atrtp_type {
ATRTP_XH20, /* In mol(H2O)/mol(mixture) */
ATRTP_XCO2, /* In mol(CO2)/mol(mixture) */
ATRTP_XCO, /* In mol(CO)/mol(mixture) */
- ATRTP_VOLFRAC_SOOT, /* In m^3(soot)/m^3 */
+ ATRTP_SOOT_VOLFRAC, /* In m^3(soot)/m^3 */
+ ATRTP_SOOT_PRIMARY_PARTICLES_COUNT, /* #primary particles per aggregate */
+ ATRTP_SOOT_PRIMARY_PARTICLES_DIAMETER, /* Primary particles diameter in nm */
ATRTP_COUNT__
};
struct atrtp_desc {
const double* properties; /* List of double[ATRTP_COUNT__] */
- size_t ncells;
+ size_t nnodes;
};
static const struct atrtp_desc ATRTP_DESC_NULL;
@@ -99,10 +101,10 @@ atrtp_get_desc
static INLINE const double*
atrtp_desc_get_node_properties
(const struct atrtp_desc* desc,
- const size_t icell)
+ const size_t inode)
{
- ASSERT(desc && icell < desc->ncells);
- return desc->properties + icell*ATRTP_COUNT__;
+ ASSERT(desc && icell < desc->nnodes);
+ return desc->properties + inode*ATRTP_COUNT__;
}
END_DECLS
diff --git a/src/atrtp_c.h b/src/atrtp_c.h
@@ -23,7 +23,7 @@ struct mem_allocator;
struct atrtp {
uint64_t pagesize;
- uint64_t ncells;
+ uint64_t nnodes;
double* props;
size_t map_len;
diff --git a/src/test_atrtp_load.c b/src/test_atrtp_load.c
@@ -24,14 +24,14 @@
static void
check_atrtp_desc
(const struct atrtp_desc* desc,
- const uint64_t ncells)
+ const uint64_t nnodes)
{
size_t icell;
CHK(desc);
- CHK(ncells);
+ CHK(nnodes);
- CHK(desc->ncells == ncells);
- FOR_EACH(icell, 0, ncells) {
+ CHK(desc->nnodes == nnodes);
+ FOR_EACH(icell, 0, nnodes) {
size_t iprop;
const double* props = atrtp_desc_get_node_properties(desc, icell);
CHK(props);
@@ -48,7 +48,7 @@ test_load(struct atrtp* atrtp)
FILE* fp = NULL;
const char* filename = "test_file.atrtp";
const uint64_t pagesize = 16384;
- const uint64_t ncells = 192;
+ const uint64_t nnodes = 192;
size_t i;
char byte = 0;
@@ -57,13 +57,13 @@ test_load(struct atrtp* atrtp)
/* Write the header */
CHK(fwrite(&pagesize, sizeof(pagesize), 1, fp) == 1);
- CHK(fwrite(&ncells, sizeof(ncells), 1, fp) == 1);
+ CHK(fwrite(&nnodes, sizeof(nnodes), 1, fp) == 1);
/* Padding */
CHK(fseek(fp, (long)ALIGN_SIZE((size_t)ftell(fp), pagesize), SEEK_SET) == 0);
/* Write nodes data */
- FOR_EACH(i, 0, ncells) {
+ FOR_EACH(i, 0, nnodes) {
double props[ATRTP_COUNT__];
int iprop;
CHK(ATRTP_COUNT__ < 10);
@@ -89,14 +89,14 @@ test_load(struct atrtp* atrtp)
rewind(fp);
CHK(atrtp_load_stream(atrtp, fp, filename) == RES_OK);
CHK(atrtp_get_desc(atrtp, &desc) == RES_OK);
- check_atrtp_desc(&desc, ncells);
+ check_atrtp_desc(&desc, nnodes);
CHK(atrtp_load(NULL, filename) == RES_BAD_ARG);
CHK(atrtp_load(atrtp, NULL) == RES_BAD_ARG);
CHK(atrtp_load(atrtp, "nop") == RES_IO_ERR);
CHK(atrtp_load(atrtp, filename) == RES_OK);
CHK(atrtp_get_desc(atrtp, &desc) == RES_OK);
- check_atrtp_desc(&desc, ncells);
+ check_atrtp_desc(&desc, nnodes);
fclose(fp);
}
@@ -107,7 +107,7 @@ test_load_fail(struct atrtp* atrtp)
const char byte = 1;
FILE* fp = NULL;
uint64_t pagesize;
- uint64_t ncells;
+ uint64_t nnodes;
CHK(atrtp);
@@ -115,11 +115,11 @@ test_load_fail(struct atrtp* atrtp)
fp = tmpfile();
CHK(fp);
pagesize = 4097;
- ncells = 10;
+ nnodes = 10;
CHK(fwrite(&pagesize, sizeof(pagesize), 1, fp) == 1);
- CHK(fwrite(&ncells, sizeof(ncells), 1, fp) == 1);
+ CHK(fwrite(&nnodes, sizeof(nnodes), 1, fp) == 1);
CHK(fseek(fp, (long)ALIGN_SIZE((size_t)ftell(fp), pagesize), SEEK_SET) == 0);
- CHK(fseek(fp, (long)(sizeof(double[ATRTP_COUNT__])*ncells), SEEK_CUR) == 0);
+ CHK(fseek(fp, (long)(sizeof(double[ATRTP_COUNT__])*nnodes), SEEK_CUR) == 0);
CHK(fseek(fp, (long)ALIGN_SIZE((size_t)ftell(fp), pagesize)-1, SEEK_SET) == 0);
CHK(fwrite(&byte, sizeof(byte), 1, fp) == 1); /* Positioned the EOF */
rewind(fp);
@@ -130,11 +130,11 @@ test_load_fail(struct atrtp* atrtp)
fp = tmpfile();
CHK(fp);
pagesize = (uint64_t)sysconf(_SC_PAGESIZE);
- ncells = 10;
+ nnodes = 10;
CHK(fwrite(&pagesize, sizeof(pagesize), 1, fp) == 1);
- CHK(fwrite(&ncells, sizeof(ncells), 1, fp) == 1);
+ CHK(fwrite(&nnodes, sizeof(nnodes), 1, fp) == 1);
CHK(fseek(fp, (long)ALIGN_SIZE((size_t)ftell(fp), pagesize), SEEK_SET) == 0);
- CHK(fseek(fp, (long)(sizeof(double[ATRTP_COUNT__])*ncells), SEEK_CUR) == 0);
+ CHK(fseek(fp, (long)(sizeof(double[ATRTP_COUNT__])*nnodes), SEEK_CUR) == 0);
CHK(fseek(fp, (long)ALIGN_SIZE((size_t)ftell(fp), pagesize)-2, SEEK_SET) == 0);
CHK(fwrite(&byte, sizeof(byte), 1, fp) == 1); /* Positioned the EOF */
@@ -156,7 +156,7 @@ test_load_files(struct atrtp* atrtp, int argc, char** argv)
CHK(atrtp_load(atrtp, argv[i]) == RES_OK);
CHK(atrtp_get_desc(atrtp, &desc) == RES_OK);
- FOR_EACH(icell, 0, desc.ncells) {
+ FOR_EACH(icell, 0, desc.nnodes) {
const double* props = atrtp_desc_get_node_properties(&desc, icell);
size_t iprop;
FOR_EACH(iprop, 0, ATRTP_COUNT__) {
@@ -167,8 +167,10 @@ test_load_files(struct atrtp* atrtp, int argc, char** argv)
CHK(props[ATRTP_XH20] >= 0);
CHK(props[ATRTP_XCO2] >= 0);
CHK(props[ATRTP_XCO] >= 0);
- CHK(props[ATRTP_VOLFRAC_SOOT] >= 0);
- CHK(props[ATRTP_VOLFRAC_SOOT] <= 1);
+ CHK(props[ATRTP_SOOT_VOLFRAC] >= 0);
+ CHK(props[ATRTP_SOOT_VOLFRAC] <= 1);
+ CHK(props[ATRTP_SOOT_PRIMARY_PARTICLES_COUNT] > 0);
+ CHK(props[ATRTP_SOOT_PRIMARY_PARTICLES_DIAMETER] > 0);
}
}
}