@@ -241,7 +241,6 @@ def test_rmg_database_schema():
241241def test_rmg_species_schema ():
242242 """Test creating an instance of RMGSpecies"""
243243 rmg_species = RMGSpecies (label = 'N2' ,
244- concentration = 1 ,
245244 smiles = 'N#N' ,
246245 inchi = '1S/N2/c1-2' ,
247246 adjlist = """
@@ -258,7 +257,7 @@ def test_rmg_species_schema():
258257 seed_all_rads = ['radical' , 'alkoxyl' , 'peroxyl' ],
259258 )
260259 assert rmg_species .label == 'N2'
261- assert rmg_species .concentration == 1
260+ assert rmg_species .concentration == 1 # automatically set if not specified
262261 assert rmg_species .smiles == 'N#N'
263262 assert rmg_species .inchi == '1S/N2/c1-2'
264263 # adjlist must be in the same column as adjlist above
@@ -275,6 +274,12 @@ def test_rmg_species_schema():
275274 assert rmg_species .solvent is False
276275 assert rmg_species .seed_all_rads == ['radical' , 'alkoxyl' , 'peroxyl' ]
277276
277+ rmg_species = RMGSpecies (label = 'H2O' ,
278+ concentration = [0.203 , 0.502 ],
279+ smiles = 'O' ,
280+ )
281+ assert rmg_species .concentration == (0.203 , 0.502 )
282+
278283 with pytest .raises (ValidationError ):
279284 # check that concentration is constrained to >= 0
280285 RMGSpecies (concentration = - 1 )
@@ -299,6 +304,50 @@ def test_rmg_species_schema():
299304 seed_all_rads = ['radical' , 'non-supported' ],
300305 )
301306
307+ with pytest .raises (ValidationError ):
308+ # check that the concentration of a balance species is not a list
309+ RMGSpecies (label = 'H2O' ,
310+ concentration = [0.203 , 0.502 ],
311+ smiles = 'O' ,
312+ balance = True ,
313+ )
314+
315+ with pytest .raises (ValidationError ):
316+ # check that concentration cannot be a 3-length tuple
317+ RMGSpecies (label = 'H2O' ,
318+ concentration = [0.203 , 0.502 , 0.809 ],
319+ smiles = 'O' ,
320+ )
321+
322+ with pytest .raises (ValidationError ):
323+ # check that concentration cannot be negative
324+ RMGSpecies (label = 'H2O' ,
325+ concentration = - 0.203 ,
326+ smiles = 'O' ,
327+ )
328+
329+ with pytest .raises (ValidationError ):
330+ # check that a concentration range cannot include a negative number
331+ RMGSpecies (label = 'H2O' ,
332+ concentration = [0.203 , - 0.502 ],
333+ smiles = 'O' ,
334+ )
335+
336+ with pytest .raises (ValidationError ):
337+ # check that a concentration range does not contain two equal boundaries
338+ RMGSpecies (label = 'H2O' ,
339+ concentration = [0.203 , 0.203 ],
340+ smiles = 'O' ,
341+ )
342+
343+ with pytest .raises (ValidationError ):
344+ # check that species defined with a concentration range cannot be constant
345+ RMGSpecies (label = 'H2O' ,
346+ concentration = [0.203 , 0.502 ],
347+ smiles = 'O' ,
348+ constant = True ,
349+ )
350+
302351
303352def test_rmg_reactors_schema ():
304353 """Test creating an instance of RMGReactor"""
0 commit comments