牛顿迭代震源定位算法模拟软件

版权申诉
0 下载量 99 浏览量 更新于2024-11-14 收藏 1KB RAR 举报
资源摘要信息:"该资源是一个关于地震波场模拟的程序压缩包,文件名为'wave_field_simulation_program_of_Ⅰ_layer.rar_wave_牛顿 定位_牛顿 迭代定位_'。根据提供的标题和描述,这个压缩包中的文件包含了使用牛顿迭代法进行震源定位的代码。牛顿迭代法是一种在数学和工程计算中广泛使用的数值方法,用于求解方程的根。在地震学中,震源定位是确定地震发生位置的关键技术,通常涉及计算地震波从震源到达多个地震站的时间差,进而利用这些时间差来估算震源位置。 牛顿迭代法是一种迭代优化技术,它通过不断逼近函数的根来解决非线性方程组。该方法的基本思想是从一个初始估计值开始,通过计算函数及其导数,迭代地改进这个估计值,直到满足预定的精度要求。在震源定位的背景下,牛顿迭代法可以用来优化震源的位置参数,使得观测到的地震波到达时间与通过模型计算得到的预测到达时间之间的差异最小化。 在给定的标签中,'wave'表示该程序与波动(如地震波)有关;'定位'和'迭代定位'则强调了震源定位过程中的迭代计算;'牛顿'一词在每个标签中都出现,强调了牛顿迭代法作为主要算法的应用。标签的组合提供了关于程序功能的清晰概览。 压缩包内的具体文件名为'hww.m'和'hww.rar'。文件扩展名'.m'表明'hww.m'是一个MATLAB脚本文件,这表明该程序可能是使用MATLAB语言编写的,MATLAB是一种广泛应用于工程计算和数值分析的编程环境。而'.rar'是一种文件压缩格式,它表示'hww.rar'可能包含了与'hww.m'相关的其他文件,如数据文件、辅助脚本或者模型参数等。由于文件的具体内容没有详细描述,我们无法确定其确切功能,但可以合理推测'hww.rar'可能包含了为了运行'hww.m'脚本所必需的额外资源。 综上所述,这个资源摘要信息表明,用户可以期望在解压缩'wave_field_simulation_program_of_Ⅰ_layer.rar_wave_牛顿 定位_牛顿 迭代定位_'文件后,找到一个基于MATLAB平台的地震波场模拟与震源定位程序。这个程序利用牛顿迭代法来优化计算震源位置的过程。用户需要具备一定的编程和地震学知识,以便正确理解和使用该程序。"

import numpy as np import matplotlib.pyplot as plt import math def count(lis): lis = np.array(lis) key = np.unique(lis) x = [] y = [] for k in key: mask = (lis == k) list_new = lis[mask] v = list_new.size x.append(k) y.append(v) return x, y mu = [14, 23, 22] sigma = [2, 3, 4] tips = ['design', 'build', 'test'] figureIndex = 0 fig = plt.figure(figureIndex, figsize=(10, 8)) color = ['r', 'g', 'b'] ax = fig.add_subplot(111) for i in range(3): x = np.linspace(mu[i] - 3*sigma[i], mu[i] + 3*sigma[i], 100) y_sig = np.exp(-(x - mu[i])**2/(2*sigma[i]**2))/(math.sqrt(2*math.pi)) ax.plot = (x, y_sig, color[i] + '-') ax.legend(loc='best', frameon=False) ax.set_xlabel('# of days') ax.set_ylabel('probability') plt.show() plt.grid(True) size = 100000 samples = [np.random.normal(mu[i], sigma[i], size) for i in range(3)] data = np.zeros(len(samples[1])) for i in range(len(samples[1])): for j in range(3): data[i] += samples[j][i] data[i] = int(data[i]) a, b = count(data) pdf = [x/size for x in b] cdf = np.zeros(len(a)) for i in range(len(a)): if i > 0: cdf[i] += cdf[i - 1] cdf = cdf/size figureIndex += 1 fig = plt.figure(figureIndex, figsize=(10, 8)) ax = fig.add_subplot(211) ax.bar(a, height=pdf, color='blue', edgecolor='white', label='MC PDF') ax.plot(a, pdf) ax.legend(loc='best', frameon=False) ax.set_xlabel('# of days for project') ax.set_ylabel('probability') ax.set_title('Monte Carlo Simulation') ax = fig.add_subplot(212) ax.plot(a, cdf) ax.legend(loc='best', frameon=False) ax.set_xlabel('# of days for project') ax.set_ylabel('probability') ax.grid(True) plt.show()修改一下代码

2023-05-18 上传

class vbase_test extends uvm_test; `uvm_component_utils(vbase_test) env m_env; vseqr m_vseqr; int unsigned simSeed; function new(string name, uvm_component parent); super.new(name, parent); endfunction : new extern function void build_phase (uvm_phase phase); extern function void connect_phase (uvm_phase phase); extern task reset_phase(uvm_phase phase); extern task reset_reg_model(); extern function void end_of_elaboration_phase(uvm_phase phase); extern function void start_of_simulation_phase(uvm_phase phase); extern task main_phase(uvm_phase phase); // report test result extern virtual function void report_phase(uvm_phase phase); endclass : vbase_test function void vbase_test::build_phase (uvm_phase phase); super.build_phase(phase); m_env = env::type_id::create(.name("m_env"), .parent(this)); // virtual sequencer m_vseqr = vseqr::type_id::create(.name("m_vseqr"), .parent(this)); uvm_config_db# (uvm_object_wrapper)::set(this,"m_vseqr.main_phase","default_sequence",vBaseSeq::type_id::get()); //uvm_config_db# (uvm_object_wrapper)::set(this,"m_vseqr.main_phase","default_sequence",vUniBaseSeq#()::type_id::get()); endfunction : build_phase function void vbase_test::connect_phase (uvm_phase phase); m_vseqr.p_rm = m_env.m_reg_model; m_vseqr.i2c_seqr = m_env.m_i2c_agent.m_seqr; endfunction : connect_phase task vbase_test::reset_phase(uvm_phase phase); //`uvm_info(get_type_name(), {"REGISTER MODEL:\n", m_reg_model.sprint()}, UVM_MEDIUM) reset_reg_model(); super.reset_phase(phase); endtask task vbase_test::reset_reg_model(); forever begin wait (tb_top.reset_n == 0); m_env.m_reg_model.reset(); `uvm_info(get_type_name(), "Reseting Complete", UVM_MEDIUM) wait (tb_top.reset_n == 1); end endtask function void vbase_test::end_of_elaboration_phase(uvm_phase phase); int handle; $system("rm -rf TEST_RUNNING"); simSeed = $get_initial_random_seed(); handle = $fopen($psprintf("TEST_RUNNING_%0d",simSeed),"w"); $fclose(handle); handle = $fopen("caseSeed","w"); $fwrite(handle,"%0d",simSeed); $fclose(handle); if($test$plusargs("uvm_tree")) uvm_top.print_topology(); endfunction : end_of_elaboration_phase function void vbase_test::start_of_simulation_phase(uvm_phase phase); `uvm_info(get_type_name(), {"start of simulation for ", get_full_name()}, UVM_HIGH); endfunction : start_of_simulation_phase task vbase_test::main_phase(uvm_phase phase); phase.phase_done.set_drain_time(this, 200ns); endtask : main_phase // report test result function void vbase_test::report_phase(uvm_phase phase); uvm_report_server server; int handle; int unsigned err_num; super.report_phase(phase); server = get_report_server(); err_num = (server.get_severity_count(UVM_ERROR) + server.get_severity_count(UVM_FATAL)); simSeed = $get_initial_random_seed(); $display("\n********************************************************************************************\n"); if (err_num != 0) begin $display("TEST CASE FAILED!!!"); handle = $fopen($psprintf("TEST_FAILED_%0d",simSeed),"w"); end else begin $display("TEST CASE PASSED!!!"); handle = $fopen($psprintf("TEST_PASSED_%0d",simSeed),"w"); end $fclose(handle); $display("\n********************************************************************************************\n"); $system("rm -rf TEST_RUNNING*"); endfunction `endif

2023-07-25 上传