Skip to content

Commit

Permalink
removed the custom hash function
Browse files Browse the repository at this point in the history
  • Loading branch information
boulderdaze committed Jun 29, 2023
1 parent 003f196 commit 0e5bff7
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 26 deletions.
24 changes: 7 additions & 17 deletions include/micm/solver/state.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,19 +9,6 @@
#include <unordered_map>
#include <vector>

// custom hash function for 'Species'
namespace std
{
template<>
struct hash<micm::Species>
{
size_t operator()(const micm::Species& key)
{
return hash<std::string>()(key.name_);
}
};
} // namespace std

namespace micm
{

Expand Down Expand Up @@ -69,8 +56,8 @@ namespace micm
const std::unordered_map<std::string, double>& species_to_concentration);

// TODO: jiwon - 6/22 - can 'MUSICA name' be used as a key? Are they hashable (unique)?
// or do we just want to use index?
//
// or do we just want to use index?
//
void SetCustomRateParams();
};

Expand All @@ -84,7 +71,10 @@ namespace micm
{
}
template<template<class> class MatrixPolicy>
inline State<MatrixPolicy>::State(const std::size_t state_size, const std::size_t custom_parameters_size, const std::size_t process_size)
inline State<MatrixPolicy>::State(
const std::size_t state_size,
const std::size_t custom_parameters_size,
const std::size_t process_size)
: conditions_(1),
variable_map_(),
variables_(1, state_size, 0.0),
Expand Down Expand Up @@ -123,7 +113,7 @@ namespace micm
}
concentrations.push_back(species_ptr->second);
}

variables_[0] = concentrations;
}
} // namespace micm
12 changes: 3 additions & 9 deletions test/integration/chapman.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,15 +33,9 @@ TEST(ChapmanIntegration, CanBuildChapmanSystemUsingConfig)
micm::State state = solver.GetState();

// Set concentrations
std::unordered_map<micm::Species, double> concentrations = { { micm::Species("O"), 0.1 },
{ micm::Species("O1D"), 0.1 },
{ micm::Species("O2"), 0.1 },
{ micm::Species("O3"), 0.2 },
{ micm::Species("M"), 0.2 },
{ micm::Species("Ar"), 0.2 },
{ micm::Species("N2"), 0.3 },
{ micm::Species("H2O"), 0.3 },
{ micm::Species("CO2"), 0.3 } };
std::unordered_map<std::string, double> concentrations = { { "O", 0.1 }, { "O1D", 0.1 }, { "O3", 0.2 },
{ "O2", 0.1 }, { "M", 0.2 }, { "Ar", 0.2 },
{ "N2", 0.3 }, { "H2O", 0.3 }, { "CO2", 0.3 } };

state.SetConcentrations(solver_params.system_, concentrations);

Expand Down

0 comments on commit 0e5bff7

Please sign in to comment.