Skip to content

Commit

Permalink
modifying species names if there is a [ or ] in name
Browse files Browse the repository at this point in the history
  • Loading branch information
Nora-Khalil committed Jan 2, 2024
1 parent c4e8d53 commit c602bf5
Showing 1 changed file with 35 additions and 3 deletions.
38 changes: 35 additions & 3 deletions rmgpy/cantera_.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,19 @@ def write_nonsurface_species(spcs):
#'species' section in phases section

sorted_species = sorted(spcs, key=lambda spcs: spcs.index)
species_to_write = [get_species_identifier(spec) for spec in sorted_species]

#make sure species with "[" or "]" is in quotes
species_list_to_write = []
for spc in sorted_species:
if '[' or ']' in spc:
edited_spc_name = "'" + spc + "'"
else:
edited_spc_name = spc
species_list_to_write.append(edited_spc_name)



species_to_write = [get_species_identifier(spec) for spec in species_list_to_write]

block2 = f"""
species: [{', '.join(species_to_write)}]
Expand Down Expand Up @@ -129,14 +141,34 @@ def write_surface_species(spcs, rxns, surface_site_density):
sorted_surface_species = sorted(
surface_species, key=lambda surface_species: surface_species.index
)

#make sure species with "[" or "]" is in quotes
surface_species_list_to_write = []
for spc in sorted_surface_species:
if '[' or ']' in spc:
edited_spc_name = "'" + spc + "'"
else:
edited_spc_name = spc
surface_species_list_to_write.append(edited_spc_name)

surface_species_to_write = [
get_species_identifier(surface_species)
for surface_species in sorted_surface_species
for surface_species in surface_species_list_to_write
]

sorted_gas_species = sorted(gas_species, key=lambda gas_species: gas_species.index)

#make sure species with "[" or "]" is in quotes
gas_species_list_to_write = []
for spc in sorted_gas_species:
if '[' or ']' in spc:
edited_spc_name = "'" + spc + "'"
else:
edited_spc_name = spc
gas_species_list_to_write.append(edited_spc_name)

gas_species_to_write = [
get_species_identifier(gas_species) for gas_species in sorted_gas_species
get_species_identifier(gas_species) for gas_species in gas_species_list_to_write
]

# gas part
Expand Down

0 comments on commit c602bf5

Please sign in to comment.