官方建议的ARKODE编程步骤

本文详细介绍了如何初始化并配置多尺度模拟的环境,包括设置问题尺寸、创建初始值向量、创建并配置快速和慢速积分器,以及设置步长、指定根查找问题、时间推进和资源释放等关键步骤。内容涵盖了MPI并行环境的初始化、NVECTOR库的使用,以及ARKStep和MRIStep这两个数值积分器的接口调用和参数设置。
  1. Initialize parallel or multi-threaded environment, if appropriate.
    For example, call MPI_Init to initialize MPI if used, or set num_threads, the number of threads to use
    within the threaded vector functions, if used.

  1. Set problem dimensions, etc.
    This generally includes the problem size, N, and may include the local vector length Nlocal.
    Note: The variables N and Nlocal should be of type sunindextype.

  1. Set vector of initial values
    To set the vector y0 of initial values, use the appropriate functions defined by the particular NVECTOR implementation.
    For native SUNDIALS vector implementations (except the CUDA and RAJA based ones), use a call of the form
    y0 = N_VMake_***(…, ydata);
    if the realtype array ydata containing the initial values of 𝑦 already exists. Otherwise, create a new vector
    by making a call of the form
    y0 = N_VNew_***(…);
    and then set its elements by accessing the underlying data where it is located with a call of the form
    ydata = N_VGetArrayPointer_***(y0);
    See the sections The NVECTOR_SERIAL Module through The NVECTOR_PTHREADS Module for details.
    For the HYPRE and PETSc vector wrappers, first create and initialize the underlying vector, and then create the
    NVECTOR wrapper with a call of the form
    y0 = N_VMake_***(yvec);
    where yvec is a HYPRE or PETSc vector. Note that calls like N_VNew_***(…) and
    N_VGetArrayPointer_***(…) are not available for these vector wrappers. See the sections The
    NVECTOR_PARHYP Module and The NVECTOR_PETSC Module for details.
    If using either the CUDA- or RAJA-based vector implementations use a call of the form
    y0 = N_VMake_***(…, c);
    where c is a pointer to a suncudavec or sunrajavec vector class if this class already exists. Otherwise,
    create a new vector by making a call of the form
    N_VGetDeviceArrayPointer_***
    or
    N_VGetHostArrayPointer_***
    Note that the vector class will allocate memory on both the host and device when instantiated. See the sections
    The NVECTOR_CUDA Module and The NVECTOR_RAJA Module for details.

  1. Create an ARKStep object for the fast (inner) integration
    Call inner_arkode_mem = ARKStepCreate(…) to create the ARKStep memory block.
    ARKStepCreate() returns a void* pointer to this memory structure. See the section ARKStep initialization
    and deallocation functions for details.

  1. Configure the fast integrator
    Specify tolerances, create and attach matrix and/or solver objects, or call ARKStepSet* functions to configure
    the fast integrator as desired. See sections A skeleton of the user’s main program and Optional input functions
    for details on configuring ARKStep.
    Notes on using ARKStep as a fast integrator:
    If the inner method is not explicitly specified then the default method in the ARKStep module will be used. If
    a particular fast method is desired it should be set in this step. The slow method can be set when configuring the
    slow integrator in the following steps.
    By default the fast integrator will use adaptive step sizes. To use a fixed fast step a call to
    ARKStepSetFixedStep() should be made in this step otherwise fast integration tolerances should be set
    in this step as described in A skeleton of the user’s main program.
    If attaching a user_data pointer, it should be attached to the slow integrator in the following steps with
    MRIStepSetUserData(). This pointer will subsequently be passed to user-provided functions during the
    fast integration.
    Specifying a rootfinding problem for the fast integration is not supported. Rootfinding problems should be
    created and initialized with the slow integrator. See the steps below and MRIStepRootInit() for more
    details.
    The ARKStep module used for the fast time scale must be configured with an identity mass matrix.

  1. Create an MRIStep object for the slow (outer) integration
    Call arkode_mem = MRIStepCreate(…) to create the MRIStep memory block.
    MRIStepCreate() returns a void* pointer to this memory structure. See the section MRIStep initialization and deallocation functions for details.

  1. Set the slow step size
    Call MRIStepSetFixedStep() to specify the slow time step size.

  1. Set optional inputs
    Call MRIStepSet* functions to change any optional inputs that control the behavior of MRIStep from their
    default values. See the section Optional input functions for details.

  1. Specify rootfinding problem
    Optionally, call MRIStepRootInit() to initialize a rootfinding problem to be solved during the integration
    of the ODE system. See the section Rootfinding initialization function for general details, and the section
    Optional input functions for relevant optional input calls.

  1. Advance solution in time
    For each point at which output is desired, call
    ier = MRIStepEvolve(arkode_mem, tout, yout, &tret, itask);
    Here, itask specifies the return mode. The vector yout (which can be the same as the vector y0 above) will
    contain 𝑦(𝑡out). See the section MRIStep solver function for details.

  1. Get optional outputs
    Call MRIStepGet* and/or ARKStepGet* functions to obtain optional output from the slow or fast integrators
    respectively. See the section Optional output functions and Optional output functions for details.

  1. Deallocate memory for solution vector
    Upon completion of the integration, deallocate memory for the vector y (or yout) by calling the NVECTOR
    destructor function:
    N_VDestroy(y);

  1. Free solver memory
    Call ARKStepFree(&inner_arkode_mem) and MRIStepFree(&arkode_mem) to free
    the memory allocated for fast and slow integration modules respectively.

  1. Free linear solver and matrix memory
    Call SUNLinSolFree() and (possibly) SUNMatDestroy() to free any memory allocated for
    any linear solver and/or matrix objects created above for the fast integrator.

  1. Finalize MPI, if used
    Call MPI_Finalize to terminate MPI.

下载前可以先看下教程 https://pan.quark.cn/s/a4b39357ea24 在网页构建过程中,表单(Form)扮演着用户与网站之间沟通的关键角色,其主要功能在于汇集用户的各类输入信息。 JavaScript作为网页开发的核心技术,提供了多样化的API和函数来操作表单组件,诸如input和select等元素。 本专题将详细研究如何借助原生JavaScript对form表单进行视觉优化,并对input输入框与select下拉框进行功能增强。 一、表单基础1. 表单组件:在HTML语言中,<form>标签用于构建一个表单,该标签内部可以容纳多种表单组件,包括<input>(输入框)、<select>(下拉框)、<textarea>(多行文本输入区域)等。 2. 表单参数:诸如action(表单提交的地址)、method(表单提交的协议,为GET或POST)等属性,它们决定了表单的行为特性。 3. 表单行为:诸如onsubmit(表单提交时触发的动作)、onchange(表单元素值变更时触发的动作)等事件,能够通过JavaScript进行响应式处理。 二、input元素视觉优化1. CSS定制:通过设定input元素的CSS属性,例如border(边框)、background-color(背景色)、padding(内边距)、font-size(字体大小)等,能够调整其视觉表现。 2. placeholder特性:提供预填的提示文字,以帮助用户明确输入框的预期用途。 3. 图标集成:借助:before和:after伪元素或者额外的HTML组件结合CSS定位技术,可以在输入框中嵌入图标,从而增强视觉吸引力。 三、select下拉框视觉优化1. 复选功能:通过设置multiple属性...
【EI复现】基于深度强化学习的微能源网能量管理与优化策略研究(Python代码实现)内容概要:本文围绕“基于深度强化学习的微能源网能量管理与优化策略”展开研究,重点探讨了如何利用深度强化学习技术对微能源系统进行高效的能量管理与优化调度。文中结合Python代码实现,复现了EI级别研究成果,涵盖了微电网中分布式能源、储能系统及负荷的协调优化问题,通过构建合理的奖励函数与状态空间模型,实现对复杂能源系统的智能决策支持。研究体现了深度强化学习在应对不确定性可再生能源出力、负荷波动等挑战中的优势,提升了系统运行的经济性与稳定性。; 适合人群:具备一定Python编程基础和机器学习背景,从事能源系统优化、智能电网、强化学习应用等相关领域的研究生、科研人员及工程技术人员。; 使用场景及目标:①应用于微能源网的能量调度与优化控制,提升系统能效与经济效益;②为深度强化学习在能源管理领域的落地提供可复现的技术路径与代码参考;③服务于学术研究与论文复现,特别是EI/SCI级别高水平论文的仿真实验部分。; 阅读建议建议读者结合提供的Python代码进行实践操作,深入理解深度强化学习算法在能源系统建模中的具体应用,重点关注状态设计、动作空间定义与奖励函数构造等关键环节,并可进一步扩展至多智能体强化学习或与其他优化算法的融合研究。
【3D应力敏感度分析拓扑优化】【基于p-范数全局应力衡量的3D敏感度分析】基于伴随方法的有限元分析和p-范数应力敏感度分析(Matlab代码实现)内容概要:本文介绍了基于伴随方法的有限元分析与p-范数全局应力衡量的3D应力敏感度分析技术,并提供了相应的Matlab代码实现。该方法主要用于拓扑优化中对应力约束的高效处理,通过引入p-范数将局部应力响应转化为全局化度量,结合伴随法精确高效地计算设计变量的敏感度,从而指导结构优化迭代。文中涵盖了有限元建模、应力评估、敏感度推导与数值实现等关键步骤,适用于复杂三维结构的轻量化与高强度设计。; 适合人群:具备有限元分析基础、优化理论背景及Matlab编程能力的研究生、科研人员和工程技术人员,尤其适合从事结构设计、拓扑优化及相关领域研究的专业人士。; 使用场景及目标:①实现三维结构在应力约束下的拓扑优化;②掌握伴随法在敏感度分析中的应用;③理解p-范数在全局应力构建中的作用机制;④为科研项目或工程问题提供可复现的Matlab代码支持与算法验证平台。; 阅读建议建议读者结合有限元理论与优化算法基础知识,逐步调试Matlab代码,重点关注敏感度计算模块与有限元求解的耦合逻辑,推荐通过简单算例验证后扩展至实际工程模型应用。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值