Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Fix SeismicityRate script. #3441

Open
wants to merge 4 commits into
base: develop
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ def curve_check_solution(**kwargs):
return np.array(analytical_rates)


def debug( xmlFilePath ):
def debug( xmlFilePath, hdf5FilePath, write_tables ):
#-------- Extract info from XML
parameters = getParametersFromXML( xmlFilePath )

Expand All @@ -70,51 +70,50 @@ def debug( xmlFilePath ):
while time < final_time:
tau = analytical_solution.compute_shear_stress(time, dt)
analytical_rate = analytical_solution.compute_seismic_rate(time, dt, tau)
time += dt
times.append(time)
analytical_rates.append(analytical_rate)
tau_plot.append(tau)
time += dt

if write_tables:
import csv

import csv

# Write times to a CSV file without headers
with open('shearStress_time.csv', 'w', newline='') as file:
# Write times to a CSV file without headers
with open('shearStress_time.csv', 'w', newline='') as file:
writer = csv.writer(file)
for time in times:
writer.writerow([time])

# Write tau_plot to a CSV file without headers
with open('shearStress_values.csv', 'w', newline='') as file:
# Write tau_plot to a CSV file without headers
with open('shearStress_values.csv', 'w', newline='') as file:
writer = csv.writer(file)
for tau in tau_plot:
writer.writerow([tau])

import h5py
file_path = '/usr/workspace/cusini1/geosx/geosx_dev/GEOS_2/build-quartz-gcc-12-release/Output/seismicityRate.hdf5'
with h5py.File(file_path, 'r') as file:
# List all groups
print("Keys: %s" % file.keys())

with h5py.File(hdf5FilePath, 'r') as file:
# Get the data
time = np.squeeze(file['seismicityRate Time'][:])
seismicityRate = np.squeeze(file['seismicityRate'][:])
print(time)
print(seismicityRate)

# Plot analytical (continuous line) and numerical (markers) aperture solution
fig, ax = plt.subplots(figsize=(16, 12), nrows=2, ncols=1)

ax[0].plot(times, tau_plot)
ax[0].plot(times, tau_plot, color='r', lw=4)
ax[0].set_xlabel('time [s]', weight="bold")
ax[0].set_ylabel('shear stress', weight="bold")

ax[1].plot(times, analytical_rates)
ax[1].plot(times, analytical_rates, label='Analytical Solution', color='r', lw=4)
ax[1].plot(time, seismicityRate, label='geos', color='k', lw=4)
ax[1].set_xlabel('time [s]', weight="bold")
ax[1].set_ylabel('seismic rate', weight="bold")
ax[1].legend( bbox_to_anchor=(0.1, 0.8), loc='center', borderaxespad=0., fontsize=12)
plt.savefig("seismicRate.png")

if __name__ == "__main__":
parser = argparse.ArgumentParser()
parser.add_argument('-f', '--xml-file', type=str, help='Path to XML file')
parser.add_argument('-f', '--xml-file', type=str, required=True, help='Path to XML file')
parser.add_argument('-h5', '--hdf5-file', type=str, required=True, help='Path to hdf5 file')
parser.add_argument('-wt', '--write-tables', action='store_true', help='Write the input tables.')
args = parser.parse_args()
debug( args.xml_file )
debug( args.xml_file, args.hdf5_file, args.write_tables )
Loading