汽车仿真软件ADVISOR2002 在高版本Matlab下的兼容使用方法

Advisor2002,众所周知,只支持Matlab6.5版本,但目前大多数Matlab都是高级版本。一下是总结解决了Advisor2002无法在高版本运行的问题,在Matlab2008a和2010上都运行成功!

修改步骤如下:

 

1.将ADVISOR2002patchforR13.m拷进Advisor的文件目录,如E:\Program\Advisor2002下;

 

2.在Matlab中将运行目录也改为E:\Program\Advisor2002;

 

3.Matlab的Command Window窗口输入ADVISOR2002patchforR13.m,可以以直接运行ADVISOR2002patchforR13.m,之后会看到Advisor的底层模块被不断更新;

 

4.更新完成后,在Command Window窗口输入advisor,运行advisor2002,之后点continue,如果Matlab提示出错,则找到出错的文件,一般是“get_cycle_info.m”,将第25行的“break”改成“return”,保存后重新运行advisor2002;继续找到出错的地方,将“break”改成“return”;

 

5.全部修改完后,advisor2002即可正确运行。如果第三步中更新出错,则可先做第四步,再进行第三步,三四步交替来做,直到没有提示错误。

 

 

ADVISOR2002patchforR13.m文件内容如下,大家可以新建个m文件,将下面的内容复制粘贴并保存为ADVISOR2002patchforR13.m即可。

 

%this file will updateall the block diagrams in the models directory in ADVISOR

%so that they will workin Mathworks Release 13.  This assumesthat you have ADVISOR 2002

%and it is alreadyincluded in your Matlab path which is done automatically when you type

%advisor at the commandprompt. 

%

% place this file in yourcurrent working directory in Matlab and type it's name.

%

% Here's what we postedon the advisor community web site regarding this error.

%

% Aug-30-2002 7:22 AM

%

% Regarding the booleantype problem in R13: Release 13 of Matlab has introduced

% a new type calledlogical. The problem is in the block diagrams in the accessory

% loads masked subsystem.Go to BD_PAR for instance and click on "mechanical accessory loads "

% then click on the"Mechanical Accessory Loads V2 " block. You will see a mask windowpop

% open. At the top, youwill see the "not" function used. In release 12 and earlier, this

% function returned a 1or a 0 for true and false. Now it returns a new type, logical. This

% is causing theproblems. To fix the problem, multiply by 1 (which causes a type change

% to double). That shouldfix the logical errors.

 

clear all

%change directories to the models directory

cd(strrep(which('advisor.m'),'advisor.m','models'))

 

%get the list ofeverything in the models directory

dir_list=dir;

 

%For the items in thedirectory that are .mdl files, do the following

k=1;

for i=1:length(dir_list)

    if ~isempty(strfind(dir_list(i).name,'.mdl'))

        %suppress warnings

        warning off

        open_system(dir_list(i).name);

       

        system=find_system(strrep(dir_list(i).name,'.mdl',''), 'RegExp','on', 'Name', 'Mechanical Accessory\nLoads v2 <acc>');

        %if the system in question is found do the following

        if ~isempty(system)

            %fix the system name

            z=isspace(system{1}); %find spaces and carriage returns and make sure they arejust spaces

            for j=1:length(system{1});

                if z(j)==1 ;

                    system{1}(j)=' ';

                end

            end

 

            settings=get_param(system,'maskvalues');

           

            if strcmp(settings{1}{1},'not(ess_on)') %check to see if already fixed

                settings{1}{1}='not(ess_on)*1'; %add the *1 to make it a real number instead of a boolean

                set_param(system{1},'maskvalues',settings{1})%set the mask values

               save_system(strrep(dir_list(i).name,'.mdl','')); %save theblock diagram

               saved_systems{k,1}=dir_list(i).name; %keep track of what models were updated

               k=k+1;

            end

        end

        close_system(strrep(dir_list(i).name,'.mdl',''))

    end

end

disp('ADVISOR2002 update for it to run in R13 of Matlab')

if exist('saved_systems')

    disp('the following block diagrams were changed and saved:')

    disp(saved_systems)

else

    disp('no block diagrams in the models directory needed to be updated')

end

warning on

 

  • 8
    点赞
  • 33
    收藏
    觉得还不错? 一键收藏
  • 3
    评论
advisor2002仿真软件 ADVISOR(Advanced VehIcle SimulatOR,级车辆仿真器)是由美国可再生能源实验室NREL(National RenewableEnergy Laboratory)在MATLAB和SIMULINK软件环境下开发的级车辆仿真软件。   该软件从1994年11月份开始开发和使用,最初是用来帮助美国能源部DOE(DepartmentofEnergy)开发某混合动力汽车的动力系统,随后功能逐渐扩展,目前最新的正式版本ADVISOR2002可以对传统汽车、纯电动汽车和混合动力汽车的各种性能作快速分析,是世界上能在网站上免费下载和用户数量最多的汽车仿真软件。由于该软件通过大量的实践被证实具有较好的实用性,现在世界上许多生产企业、研究机构和校都在使用软件汽车仿真方面的研究。 ADVISOR是MATLAB和SIMULINK软件环境下的一系列模型、数据和脚本文件,它在给定的道路循环条件下利用车辆各部分参数,能快速地分析传统汽车、纯电动汽车和混合动力汽车的燃油经济性、动力性以及排放性等各种性能。此外,该软件的开放性也允许对用户自定义的汽车模型和仿真策略做仿真分析。它主要有以下特点:   (1)仿真模型采用模块化的思想设计。ADVISOR软件分模块建立了发动机、离合器、变速器、主减速器、车轮和车轴等部件的仿真模型,各个模块都有标准的数据输入/输出端口,便于模块间进行数据传递,而且各总成模块都很容易扩充和修改,各模块也可以随意地组合使用,用户可以在现有模型的基础上根据需要对一些模块进行修改,然后重新组装需要的汽车模型,这样会大大节省建模时间,提建模效率。   (2)仿真模型和源代码全部开放。ADVISOR2002仿真模型和源代码在全球范围内完全公开,可以在网站上免费下载。用户可以方便地研究ADVISOR的仿真模型及其工作原理,在此基础上根据需要修改或重建部分仿真模型、调整或重新设计控制策略,使之更接近于实际情形,得出的仿真结果也会更合理。   (3)采用了独特的混合仿真方法。现在的汽车仿真方法主要有前向仿真和后向仿真两种,仿真软件也多采用其中的一种方法,使两种方法优劣不能互补,而ADVISOR采用了以后向仿真为主、前向仿真为辅的混合仿真方法,这样便较好地集成了两种方法的优点,既使仿真计算量较小,运算速度较快,同时又保证了仿真结果的精度。   (4)在MATLAB和SIMULINK软件环境下开发研制。MATLAB是世界上顶尖的可视化科学计算与数学应用软件,其语法结构简单、数值计算效、图形功能完备,集成了诸多专业仿真工具包,而且它还提供了方便的应用程序接口(API),用户可以在MATLAB环境下直接调用C、Fortran等语言编写的程序。MATLAB内置的计算程序、专业的仿真工具以及与其他应用程序的接口,会减少汽车模型的搭建和仿真计算过程中工作量,同时也方便了熟悉不同编程语言的用户之间的合作。   (5)能与其他多种软件进行联合仿真(Co-simulation)。汽车是一个复杂的系统,其仿真更是涉及机械、电子、控制等多个领域,工作量很大,ADVISOR软件开发过程中也难以涉及所有领域,这样就限制了它一些功能的实现。但是ADVISOR设计了开放的软件接口,能与Saber、Simplorer、VisuaDOC、Sinda/Fluint等软件进行联合仿真,为用户改进和拓展其功能提供了方便。   虽然ADVISOR软件也有一些缺陷,例如,它的部件模型都是准静态的(quasi-static),不能预测小于十分之一秒左右时间范围内的一些现象;机械振动、电磁振荡等许多动态特性也不能通过ADVISOR软件进行仿真,但它的优越性仍然吸引了国内外的众多用户。 使用说明: 1.确保已安装matlaB6.1以上版本; 2.运行文件夹中的SetAdvisorPath.m文件; 3.运行advisor.m文件,打开advisor; 4.以后要运行,只需在matlaB命令窗口中输入advisor命令即可。
评论 3
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值