Skip to content

Commit

Permalink
additional changes to fix species names in yaml file output
Browse files Browse the repository at this point in the history
  • Loading branch information
Nora-Khalil committed Jan 3, 2024
1 parent dd947a7 commit ad560fd
Showing 1 changed file with 19 additions and 18 deletions.
37 changes: 19 additions & 18 deletions rmgpy/cantera_.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,22 +83,21 @@ 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:
for spc in species_to_write:
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)}]
species: [{', '.join(species_list_to_write)}]
kinetics: gas"""

block3 = """
Expand Down Expand Up @@ -142,42 +141,44 @@ def write_surface_species(spcs, rxns, surface_site_density):
surface_species, key=lambda surface_species: surface_species.index
)

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

#make sure species with "[" or "]" is in quotes
surface_species_list_to_write = []
for spc in sorted_surface_species:
for spc in surface_species_to_write:
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 surface_species_list_to_write
]


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


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

#make sure species with "[" or "]" is in quotes
gas_species_list_to_write = []
for spc in sorted_gas_species:
for spc in gas_species_to_write:
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 gas_species_list_to_write
]

# gas part
block1 = f"""
phases:
- name: gas
thermo: ideal-gas
elements: [H, D, T, C, Ci, O, Oi, N, Ne, Ar, He, Si, S, F, Cl, Br, I, X]
species: [{', '.join(gas_species_to_write)}]
species: [{', '.join(gas_species_list_to_write)}]
kinetics: gas
reactions: [gas_reactions]"""

Expand All @@ -190,7 +191,7 @@ def write_surface_species(spcs, rxns, surface_site_density):
thermo: ideal-surface
adjacent-phases: [gas]
elements: [H, D, T, C, Ci, O, Oi, N, Ne, Ar, He, Si, S, F, Cl, Br, I, X]
species: [{', '.join(surface_species_to_write)}]
species: [{', '.join(surface_species_list_to_write)}]
kinetics: surface
reactions: [surface_reactions]
site-density: {surface_site_density * 1e-4 }
Expand Down

0 comments on commit ad560fd

Please sign in to comment.