C++ 实现:模拟时间演化的维粘性汉堡方程

C/C++ 专栏收录该内容
¥99.90 ¥299.90
204篇文章

C++ 实现:模拟时间演化的维粘性汉堡方程

维粘性汉堡方程是一种描述物质中扩散和粘性效应的非线性偏微分方程。在本文中,我们将使用 C++ 编程语言实现一个模拟时间演化的维粘性汉堡方程的数值解算器。

首先,让我们回顾一下维粘性汉堡方程的方程形式:

∂u/∂t = ν∇²u - (∇⋅(u⋅∇)u)

其中,u 是一个二维向量场,表示物质的速度场;t 是时间;ν 是粘性系数;∇² 是拉普拉斯算子;∇ 是梯度算子;⋅ 表示向量的点乘运算;和 ∇⋅ 表示向量的散度运算。

为了数值求解这个方程,我们将使用有限差分方法来近似偏微分算子。我们将使用一个二维网格来离散化空间,并使用显式欧拉方法来离散化时间。让我们开始编写代码。

#include <iostream>
#include <vector>

比较 WENO5-JS、WENO5-M 和 WENO5-Z:比较 5 阶 WENO 方案的三种最流行的实现。-matlab开发 从蒋和舒的经典 WENO 配方 (WENO5-JS) 开始,在过去的二十年中已经报道了许多配方的改进。 迄今为止,众所周知,两种配方因其简单性和对经典 WENO5-SJ 的实质性改进而脱颖而出。 这些公式是 A. Henrick (WENO5-M) 的映射 WENO5 和 R. Borges 的 WENO5-Z 公式。 本 repo 的片段中描述了每个单独重建的一维实现。 本代码旨在作为该方法实现的指南。 当前代码段背后的哲学是可读而不是高效的代码。 曼努埃尔·A·迪亚兹 (2017) 立即下载

相关推荐

Fortran:WENO格式求解一维Euler方程,包含WENO、WENO-Z、WENO-ZN等格式

Fortran:WENO格式求解一维Euler方程,包含WENO、WENO-Z、WENO-ZN等格式。 运行前请通过ini.txt设置计算条件 介绍 WENO格式求解一维Euler方程,包含特征重构,有5阶\7阶精度 算例 黎曼问题、Shu-Osher、Titarev–Toro、Blasting-Wave 通量分裂 当地\全局LF分裂、SW分裂、vanLeer分裂 WENO重构 WENO-JS, WENO-z, WENO-zn等格式

WENO5_1DB.zip_BURGER_WENO格式_weno matlab_weno方程

使用5阶WENO格式,3阶RK格式,LF通量分裂,对一维Burger s方程进行求解。所得结果可以与《Weighted Essentially Non-Oscillatory Schemes》1994中结果进行对比

Burgers方程_牛顿迭代法.zip_Buegers方程求解_Burgers_Newton_burgers_牛顿迭代_迭代法

用牛顿迭代法求解Buegers方程的精确解

CASS3D实战:高效三维房屋与地形采集绘制技巧

本文详细介绍了CASS3D在三维房屋与地形采集绘制中的高效技巧,包括智能绘房功能、不规则结构处理、特殊构件快速绘制及地形数据采集策略。通过实战案例和进阶操作指南,帮助用户快速掌握CASS3D的核心功能,提升三维采集与绘制效率。

weixin_29216049的博客 868

P450酶催化循环的Amber-Gromacs混合模拟实战:从血红素加氧到产物释放

本文详细介绍了针对P450酶完整催化循环的Amber-Gromacs混合模拟实战策略。通过Amber为关键氧合血红素中间体(CPDI)构建精确力场,再利用Gromacs的高效GPU加速进行长时间尺度动力学模拟,完整覆盖从底物结合到产物释放的催化过程,为研究酶催化机制提供了强大的计算工具。

weixin_29201859的博客 315

实战神器指标解析 篇四:主力吸筹指标及其分析和使用说明

主力可能会进行多次吸筹,因此需要根据黄色趋势线来判断是否有转强的变化。一旦出现转强的迹象,这通常意味着吸筹已经接近尾声,即将进入拉升前期。此时可以介入进行建仓。该股票指标通过分析价格变动的方式,能够精确跟踪并标识主力的吸筹行为。当底部出现多根洋红色柱子时,这通常表示出现了主力吸筹的指示。这段代码主要用于分析股票的底部吸筹情况、趋势和涨跌情况。

生活在别处 6228

【YOLOv11改进[Backbone]】 使用Ghostnetv2替换Backbone

使用Ghostnetv2替换Backbone

静谧、淡雅 518

一文掌握 MongoDB 详细安装与配置(Windows / Linux / macOS 全平台)

本文详细介绍了MongoDB社区版7.0+在Windows、Linux和macOS三大操作系统上的完整安装、配置与安全加固流程。主要内容包括:各平台推荐安装方式(Windows使用MSI安装包、Linux通过官方仓库、macOS通过Homebrew)、基本配置参数说明、服务启动方法以及关键安全措施(如创建管理员用户和启用身份验证)。文章还提供了系统最低要求、下载地址、数据目录设置建议以及生产环境使用注意事项,适合开发、测试及生产环境部署参考。

数据知道的博客 6715

海康威视 2024届 数字逻辑设计 实习笔试分析

记录一下 5月11日晚,做的海康威视的一场笔试。分享给需要的IC人。 岗位:数字逻辑设计工程师(浙江 杭州) 转载需要本人同意! 我的见解不一定都是准确的,欢迎评论区交流指正~~

记录所学,分享知识,结识挚友 1万+

Loop Engineering 来了:从写 Prompt 到设计 Loop,AI 编程的第四次范式跃迁

文章摘要: Loop Engineering是AI编程领域的新范式,标志着从"人手动喂指令"到"设计自驱动循环"的跃迁。其核心在于通过五个组件(定时器、工作空间、知识体系、连接器和子Agent验证)构建自动化任务流,使AI系统能自主运行。这一概念的火爆源于模型能力和工具链的成熟,使得任务设计成为关键瓶颈。作者指出,从Prompt到Loop的四次范式跃迁(语言学→信息科学→控制论→管理学)反映了人机协作关系的根本变化:人类角色从执行者逐渐退居为目标设定者。落地Loop Engineering的真正挑战在于目标

少说,多做 330

Python 爬虫实战:爬取哔哩哔哩知识区,抓取高赞课程信息

哔哩哔哩(Bilibili)是一个广受欢迎的综合性视频社区,其中的知识区汇聚了大量优质的教育、科普、技术等课程内容。本文将指导读者如何使用 Python 爬虫技术从哔哩哔哩知识区抓取高赞课程信息,并进行数据分析。本文深入探究了利用 Python 爬虫技术从哔哩哔哩知识区抓取高赞课程信息的全流程。从前期的环境搭建、模拟登录,到核心的课程数据抓取、存储,再到后续的数据分析与可视化,都详细展开讲解并提供代码支持。通过此方法所获取的数据,能够助力创作者优化内容、用户发现优质课程、平台洞察用户需求。

u014481728的博客 1137

汉书HE8,好用的汇编代码编写工具

汉书HE8,好用的汇编代码编写工具早期编写汇编代码所用功能强大

锂电池充电器电路设计 里面有电路

锂电池充电器电路设计 里面有电路 3.7V升压到5V电路设计。

lwip-2.0.3

lwip是瑞典计算机科学院(SICS)的Adam Dunkels 开发的一个小型开源的TCP/IP协议栈。实现的重点是在保持TCP协议主要功能的基础上减少对RAM 的占用。

深度学习工具包 DeepLearningToolbox

深度学习工具包Deprecation notice.-----This toolbox is outdated and no longer maintained.There are much better tools available for deep learning than this toolbox, e.g. [Theano](http://deeplearning.net/software/theano/), [torch](http://torch.ch/) or [tensorflow](http://www.tensorflow.org/)I would suggest you use one of the tools mentioned above rather than use this toolbox.Best, Rasmus.DeepLearnToolbox================A Matlab toolbox for Deep Learning.Deep Learning is a new subfield of machine learning that focuses on learning deep hierarchical models of data.It is inspired by the human brain's apparent deep (layered, hierarchical) architecture.A good overview of the theory of Deep Learning theory is[Learning Deep Architectures for AI](http://www.iro.umontreal.ca/~bengioy/papers/ftml_book.pdf)For a more informal introduction, see the following videos by Geoffrey Hinton and Andrew Ng.* [The Next Generation of Neural Networks](http://www.youtube.com/watch?v=AyzOUbkUf3M) (Hinton, 2007)* [Recent Developments in Deep Learning](http://www.youtube.com/watch?v=VdIURAu1-aU) (Hinton, 2010)* [Unsupervised Feature Learning and Deep Learning](http://www.youtube.com/watch?v=ZmNOAtZIgIk) (Ng, 2011)If you use this toolbox in your research please cite [Prediction as a candidate for learning deep hierarchical models of data](http://www2.imm.dtu.dk/pubdb/views/publication_details.php?id=6284)```@MASTERSTHESIS\{IMM2012-06284, author = "R. B. Palm", title = "Prediction as a candidate for learning deep hierarchical models of data", year = "2012",}```Contact: rasmusbergpalm at gmail dot comDirectories included in the toolbox-----------------------------------`NN/` - A library for Feedforward Backpropagation Neural Networks`CNN/` - A library for Convolutional Neural Networks`DBN/` - A library for Deep Belief Networks`SAE/` - A library for Stacked Auto-Encoders`CAE/` - A library for Convolutional Auto-Encoders`util/` - Utility functions used by the libraries`data/` - Data used by the examples`tests/` - unit tests to verify toolbox is workingFor references on each library check REFS.mdSetup-----1. Download.2. addpath(genpath('DeepLearnToolbox'));Example: Deep Belief Network---------------------```matlabfunction test_example_DBNload mnist_uint8;train_x = double(train_x) / 255;test_x = double(test_x) / 255;train_y = double(train_y);test_y = double(test_y);%% ex1 train a 100 hidden unit RBM and visualize its weightsrand('state',0)dbn.sizes = [100];opts.numepochs = 1;opts.batchsize = 100;opts.momentum = 0;opts.alpha = 1;dbn = dbnsetup(dbn, train_x, opts);dbn = dbntrain(dbn, train_x, opts);figure; visualize(dbn.rbm{1}.W'); % Visualize the RBM weights%% ex2 train a 100-100 hidden unit DBN and use its weights to initialize a NNrand('state',0)%train dbndbn.sizes = [100 100];opts.numepochs = 1;opts.batchsize = 100;opts.momentum = 0;opts.alpha = 1;dbn = dbnsetup(dbn, train_x, opts);dbn = dbntrain(dbn, train_x, opts);%unfold dbn to nnnn = dbnunfoldtonn(dbn, 10);nn.activation_function = 'sigm';%train nnopts.numepochs = 1;opts.batchsize = 100;nn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.10, 'Too big error');```Example: Stacked Auto-Encoders---------------------```matlabfunction test_example_SAEload mnist_uint8;train_x = double(train_x)/255;test_x = double(test_x)/255;train_y = double(train_y);test_y = double(test_y);%% ex1 train a 100 hidden unit SDAE and use it to initialize a FFNN% Setup and train a stacked denoising autoencoder (SDAE)rand('state',0)sae = saesetup([784 100]);sae.ae{1}.activation_function = 'sigm';sae.ae{1}.learningRate = 1;sae.ae{1}.inputZeroMaskedFraction = 0.5;opts.numepochs = 1;opts.batchsize = 100;sae = saetrain(sae, train_x, opts);visualize(sae.ae{1}.W{1}(:,2:end)')% Use the SDAE to initialize a FFNNnn = nnsetup([784 100 10]);nn.activation_function = 'sigm';nn.learningRate = 1;nn.W{1} = sae.ae{1}.W{1};% Train the FFNNopts.numepochs = 1;opts.batchsize = 100;nn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.16, 'Too big error');```Example: Convolutional Neural Nets---------------------```matlabfunction test_example_CNNload mnist_uint8;train_x = double(reshape(train_x',28,28,60000))/255;test_x = double(reshape(test_x',28,28,10000))/255;train_y = double(train_y');test_y = double(test_y');%% ex1 Train a 6c-2s-12c-2s Convolutional neural network %will run 1 epoch in about 200 second and get around 11% error. %With 100 epochs you'll get around 1.2% errorrand('state',0)cnn.layers = { struct('type', 'i') %input layer struct('type', 'c', 'outputmaps', 6, 'kernelsize', 5) %convolution layer struct('type', 's', 'scale', 2) %sub sampling layer struct('type', 'c', 'outputmaps', 12, 'kernelsize', 5) %convolution layer struct('type', 's', 'scale', 2) %subsampling layer};cnn = cnnsetup(cnn, train_x, train_y);opts.alpha = 1;opts.batchsize = 50;opts.numepochs = 1;cnn = cnntrain(cnn, train_x, train_y, opts);[er, bad] = cnntest(cnn, test_x, test_y);%plot mean squared errorfigure; plot(cnn.rL);assert(er<0.12, 'Too big error');```Example: Neural Networks---------------------```matlabfunction test_example_NNload mnist_uint8;train_x = double(train_x) / 255;test_x = double(test_x) / 255;train_y = double(train_y);test_y = double(test_y);% normalize[train_x, mu, sigma] = zscore(train_x);test_x = normalize(test_x, mu, sigma);%% ex1 vanilla neural netrand('state',0)nn = nnsetup([784 100 10]);opts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samples[nn, L] = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.08, 'Too big error');%% ex2 neural net with L2 weight decayrand('state',0)nn = nnsetup([784 100 10]);nn.weightPenaltyL2 = 1e-4; % L2 weight decayopts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex3 neural net with dropoutrand('state',0)nn = nnsetup([784 100 10]);nn.dropoutFraction = 0.5; % Dropout fraction opts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex4 neural net with sigmoid activation functionrand('state',0)nn = nnsetup([784 100 10]);nn.activation_function = 'sigm'; % Sigmoid activation functionnn.learningRate = 1; % Sigm require a lower learning rateopts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex5 plotting functionalityrand('state',0)nn = nnsetup([784 20 10]);opts.numepochs = 5; % Number of full sweeps through datann.output = 'softmax'; % use softmax outputopts.batchsize = 1000; % Take a mean gradient step over this many samplesopts.plot = 1; % enable plottingnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex6 neural net with sigmoid activation and plotting of validation and training error% split training data into training and validation datavx = train_x(1:10000,:);tx = train_x(10001:end,:);vy = train_y(1:10000,:);ty = train_y(10001:end,:);rand('state',0)nn = nnsetup([784 20 10]); nn.output = 'softmax'; % use softmax outputopts.numepochs = 5; % Number of full sweeps through dataopts.batchsize = 1000; % Take a mean gradient step over this many samplesopts.plot = 1; % enable plottingnn = nntrain(nn, tx, ty, opts, vx, vy); % nntrain takes validation set as last two arguments (optionally)[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');```[![Bitdeli Badge](https://d2weczhvl823v0.cloudfront.net/rasmusbergpalm/deeplearntoolbox/trend.png)](https://bitdeli.com/free "Bitdeli Badge")

上一篇: boost::astar_search算法实现及测试
下一篇: DICOM:RLE压缩转图像文件的实现方法
普通网友
博客等级 码龄4年 1011粉丝 1742原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符  | 博主筛选后可见
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

当前余额3.43元 前往充值 >
需支付:10.00元
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

编码实践

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付元
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值