|
[Sponsors] |
error C2109: subscript requires array or pointer type |
|
LinkBack | Thread Tools | Search this Thread | Display Modes |
November 9, 2016, 01:51 |
error C2109: subscript requires array or pointer type
|
#1 |
New Member
meljuntak
Join Date: Nov 2016
Posts: 7
Rep Power: 9 |
Hi everyone...
I am a Ph.D. Student with research about simulation of coal drying. In my simulation I use UDF based on DPM multicomponent model as shown in UDF Guide for DPM_Heat_and_Mass_Transfer, I use Ansys Fluent 12 version with the transient model, injection of particle occur on 60 t0 61 second, as much as 600 gr. After I compile my UDF there are occur error as shown below multivap.c(56) : error C2109: subscript requires array or pointer type multivap.c(57) : error C2109: subscript requires array or pointer type This error due to part of udf line 56 and 57 56 P_total += cvap_surf[ns]; 57 dens_total += cvap_surf[ns] * molwt[gas_index]; Did someone ever do this case and how to solve the problem?? Whether this simulation needs to be initialized vaporization and injection must be written in UDF also??? Thankyou very much Melvin My complete UDF was written as below #include "udf.h" DEFINE_DPM_HEAT_MASS(multivap,p,Cp,hgas,hvap,cvap_ bulk,cvap_surf,dydt,dzdt) { int ns ; /*declaring variable ns as an integer*/ int nc = TP_N_COMPONENTS( p ); /* number of particle component */ real dens_total = 0.0; /*total vapor density*/ real P_total = 0.0; /*vapor pressure*/ cell_t c0 = RP_CELL( &(p->cCell) ); /* cell and thread */ Thread *t0 = RP_THREAD( &(p->cCell) ); /* where the particle is in */ Material *gas_mix = THREAD_MATERIAL( t0 ); /* gas mixture material */ Material *cond_mix = p->injection->material; /* particle mixture material */ cphase_state_t *c =&(p->cphase); /*cell info of particle location */ real molwt[MAX_SPE_EQNS]; /* molecular weightf gas species */ real Tp = P_T(p); /* particle temperature */ real mp = P_MASS(p); /* particle mass */ real molwt_bulk = 0.; /* average molecular weight in the bulk gas */ real Dp = DPM_DIAM_FROM_VOL( mp / P_RHO(p) ); /* particle diameter */ real Ap = DPM_AREA(Dp); /* particle surface */ real Pr = c->sHeat * c->mu / c->tCond; /* Prandtl number */ real Nu = 2.0 + 0.6 * sqrt( p->Re ) * pow( Pr, 1./3. ); /* Nusselt number */ real h = Nu * c->tCond / Dp; /* Heat transfer coefficient */ real dh_dt = h * ( c->temp - Tp ) * Ap; /* heat source term */ dydt[0] += dh_dt / ( mp * Cp ); dzdt->energy -= dh_dt; { Material *sp; mixture_species_loop(gas_mix,sp,ns) { molwt[ns] = MATERIAL_PROP(sp,PROP_mwi); /* molecular weight of gas species */ molwt_bulk += C_YI(c0,t0,ns) / molwt[ns]; /* average molecular weight */ } } /* prevent division by zero */ molwt_bulk = MAX(molwt_bulk,DPM_SMALL); for( ns = 0; ns < nc; ns++ ); { /* gas species index of vaporization */ int gas_index = TP_COMPONENT_INDEX_I(p,ns); if ( gas_index >= 0 ) { Material * cond_c = MIXTURE_COMPONENT(cond_mix, ns ); /*condensed material*/ real vap_temp = MATERIAL_PROP(cond_c,PROP_vap_temp); /* vaporization temperature */ real D = MATERIAL_PROP_POLYNOMIAL(cond_c,PROP_binary_diffus ivity,c->temp); /* diffusion coefficient */ real Sc = c->mu / ( c->rho * D ); /* Schmidt number */ real k = ( 2.0 + 0.6 * sqrt(p->Re) * pow( Sc, 1./3. ) ) * D /Dp; /* mass transfer coefficient */ real cvap_bulk = c->pressure / UNIVERSAL_GAS_CONSTANT / c->temp * c->yi[gas_index] / molwt_bulk / solver_par.molWeight[gas_index]; /* bulk gas concentration */ real vap_rate = k * molwt[gas_index] * Ap * ( cvap_surf - cvap_bulk ); /* vaporization rate */ if( 0. < vap_rate && Tp < vap_temp ) vap_rate = 0.; dydt[1+ns] -= vap_rate; dzdt->species[gas_index] +=vap_rate; dydt[0] -= hvap[gas_index] * vap_rate / ( mp * Cp ); /* dT/dt = dh/dt / (m Cp) */ dzdt->energy += hgas[gas_index] * vap_rate; /* gas enthalpy source term */ P_total += cvap_surf[0, ns]; /*vapor pressure = vapor equilibrium concentration of vaporizing components*/ dens_total += cvap_surf[0, ns] * molwt[gas_index]; /*Total vapor density = mol/m3 *kg/mol*/ } } } Last edited by Melvin; November 9, 2016 at 02:52. Reason: to make looks better |
|
February 5, 2018, 17:54 |
How was it?
|
#2 |
New Member
Join Date: Jan 2018
Posts: 12
Rep Power: 8 |
Hi Melvin,
I am facing a problem similar to yours: a UDF file (.c) that works and can be compiled with no problem in ANSYS 13, but fail to compile in ANSYS 16. And yes, I am also working with DPM of multicomponent material. Can you share how you finally dealt with the problem, if you did? Regards, Daniel |
|
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
second order schemes | marine | OpenFOAM | 67 | April 11, 2022 18:19 |
[Commercial meshers] Mesh conversion problem (fluent3DMeshToFoam) | Aadhavan | OpenFOAM Meshing & Mesh Conversion | 2 | March 8, 2018 01:47 |
time step continuity problem in VAWT simulation | lpz_michele | OpenFOAM Running, Solving & CFD | 5 | February 22, 2018 19:50 |
Time step continuity error | lpz_michele | OpenFOAM Running, Solving & CFD | 0 | October 12, 2015 06:05 |
boundary conditions for simpleFoam calculation | foam_noob | OpenFOAM Running, Solving & CFD | 8 | July 1, 2015 08:07 |